#Check if target is posix
1 messages · Page 1 of 1 (latest)
you can use
const builtin = @import("builtin");
// somewhere else
if (builtin.target == .windows) ...```
Note its not the same as `std.builtin` but a generated file that fills in the `std.Target` struct
how you do the rest is up to you, it would make sense to check in build.zig and simply include correct files as a lib which have the same interface for your functions.
The other is to have it in one file that uses comptime to check the OS but that might be confusing
Yeah, I'm aware I can check os like that. That's what I'm currently doing. Just seemed fragile to check for windows and wasi, so I was hoping for a better solution
switch (builtin.os.tag) {
.windows, .wasi => nonPosixPath,
else => posixPath,
};```
I'm in over my head here (I just searched the stdlib for is.*posix) but you should maybe check for .uefi too: https://github.com/ziglang/zig/blob/master/lib/std/time.zig#L178-L182