Help debug or not debug

How can I tell whether my program is compiled in debug or release mode?

Because I would like two different behaviors

You can access the compiler variables via “builtin”

const std = @import("std");
const builtin = @import("builtin");

pub fn main() !void {
    if (builtin.mode == .Debug) {
        std.log.err("DEBUG", .{});
    } else {
        std.log.err("NOT DEBUG", .{});
    }
}

https://ziglang.org/documentation/master/#Compile-Variables

1 Like

Thanks, that way I can let the programmer choose to continue, etc. in debug mode for tests when reporting errors like “!void…”.
On the other hand, the user will get a message and a log …

Thanks