Created
February 20, 2023 21:51
-
-
Save jwhear/bac07609ca52d064ec2ecf8dae822865 to your computer and use it in GitHub Desktop.
No unistd.h for macos 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const CrossTarget = std.zig.CrossTarget; | |
pub fn build(b: *std.Build) void { | |
const target = CrossTarget{ | |
.cpu_arch = .x86_64, | |
.os_tag = .macos, | |
.os_version_min = CrossTarget.OsVersion{ .semver = .{ .major = 10, .minor = 14, .patch = 0 } }, | |
.abi = .none, | |
}; | |
const optimize = b.standardOptimizeOption(.{}); | |
var exe = b.addExecutable(.{ | |
.name = "test", | |
.root_source_file = .{ .path = "test.zig" }, | |
.target = target, | |
.optimize = optimize, | |
}); | |
exe.linkLibC(); | |
exe.install(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const unistd = @cImport({@cInclude("unistd.h");}); | |
pub fn main() !void { | |
const ticks: i64 = unistd.sysconf(unistd._SC_CLK_TCK); | |
std.debug.print("ticks = {}\n", .{ticks}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment