Skip to content

Instantly share code, notes, and snippets.

@koljakube
Created April 5, 2020 16:18
Show Gist options
  • Save koljakube/c80cc525c9ff7ef5741c3010c6f21cd5 to your computer and use it in GitHub Desktop.
Save koljakube/c80cc525c9ff7ef5741c3010c6f21cd5 to your computer and use it in GitHub Desktop.

Reproducing an unexpected behavior in zig. The current state prints

COLORS: 0

If line 8 in main.zig is commented in, it prints

COLORS: 256

Tested in iTerm2 on macOS 10.15.4.

zig build-exe --library ncurses main.zig && ./main
const std = @import("std");
pub const c = @cImport({
@cInclude("ncurses.h");
});
pub var COLORS: ?i32 = null;
pub fn start_color() void {
_ = c.start_color();
COLORS = c.COLORS;
}
const std = @import("std");
const nc = @import("import.zig");
const c = nc.c;
pub fn main() !void {
_ = c.initscr();
nc.start_color();
// const pCLRS = &c.COLORS;
if (nc.COLORS) |clrs| {
std.debug.warn("COLORS: {}\n", .{clrs});
}
std.time.sleep(1000000000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment