#Restrict code for certain targets

1 messages · Page 1 of 1 (latest)

north cedar
#

Sorry if this is a noob question, but I'm trying to port my virtual arena code from C, and since it's only implemented in Linux and Windows, I wanted to add a @compileError in case it tried to build anywhere else. However I can't seem to get the declaration syntax right.

Top-level if (comptime ... don't seem to be supported by the parser. There were no syntax errors when I tried this:

pub const ARENA = if (builtin.os.tag == .windows or builtin.os.tag == .linux) {
    @import("./mem/arena.zig").ARENA;
} else {
    @compileError("va.mem.ARENA is only supported for Windows and Linux targets");
};

But when I actually used it, I got an error message saying the type value of the @import is getting ignored.

Appreciate the help!

vivid mortar
#

just remove the braces, values arent implicitly returned from blocks