# How to check if a target supports posix

**URL:** <https://ziggit.dev/t/how-to-check-if-a-target-supports-posix/17822>\
**Category:** Help\
**Tags:** language\
**Created:** [October 3, 2026, 11:30pm UTC](https://ziggit.dev/t/how-to-check-if-a-target-supports-posix/17822 "2026-10-03T23:30:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vexo413](https://ziggit.dev/user_avatar/ziggit.dev/vexo413/32/10418_2.png) [@Vexo413](https://ziggit.dev/u/Vexo413)\
**Post date:** [October 3, 2026, 11:30pm UTC](https://ziggit.dev/t/how-to-check-if-a-target-supports-posix/17822/1 "2026-10-03T23:30:40Z")

</div>

How can I check in my code if I can run std.posix functions?  
Or do you just have to check if the OS is linux, macos, bsd, etc.

---

<div class="post-metadata">

**Author:** ![vulpesx](https://ziggit.dev/user_avatar/ziggit.dev/vulpesx/32/3989_2.png) [@vulpesx](https://ziggit.dev/u/vulpesx)\
**Post date:** [October 4, 2026, 1:16am UTC](https://ziggit.dev/t/how-to-check-if-a-target-supports-posix/17822/2 "2026-10-04T01:16:41Z")

</div>

this is the logic `std.posix` uses

```zig
const use_libc = builtin.link_libc or switch (native_os) {
    .windows, .wasi => true,
    else => false,
};

/// A libc-compatible API layer.
pub const system = if (use_libc)
    std.c
else switch (native_os) {
    .linux => linux,
    .plan9 => std.os.plan9,
    .psp => struct {
        pub const fd_t = i32;
        pub const pid_t = void;
        pub const pollfd = void;
        pub const uid_t = void;
        pub const gid_t = void;
        pub const mode_t = u32;
        pub const nlink_t = u32;
        pub const blksize_t = u32;
        pub const ino_t = u64;
        pub const IFNAMESIZE = {};
        pub const SIG = void;

        // https://github.com/pspdev/newlib/blob/9e0a073634ad73e8e088f2e071c55a9fe5d39709/newlib/libc/sys/psp/sys/dirent.h#L19
        pub const NAME_MAX = 255;
    },
    else => struct {
        pub const pid_t = void;
        pub const pollfd = void;
        pub const fd_t = void;
        pub const uid_t = void;
        pub const gid_t = void;
        pub const mode_t = u0;
        pub const nlink_t = u0;
        pub const blksize_t = void;
        pub const ino_t = void;
        pub const IFNAMESIZE = {};
        pub const SIG = void;
    },
};

```
