Skip to content

Instantly share code, notes, and snippets.

@jwhear
Created February 20, 2023 21:51
Show Gist options
  • Save jwhear/bac07609ca52d064ec2ecf8dae822865 to your computer and use it in GitHub Desktop.
Save jwhear/bac07609ca52d064ec2ecf8dae822865 to your computer and use it in GitHub Desktop.
No unistd.h for macos 10
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();
}
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