#How to include mach/mach_vm.h on macOS

1 messages · Page 1 of 1 (latest)

lofty lagoon
#

Hi,

For my project I need access to a few functions, for example mach_vm_region.
I currently have this c.zig file.

pub usingnamespace @cImport({
    @cInclude("libproc.h");
    @cInclude("mach/mach.h");
    @cInclude("mach/mach_vm.h");
    @cInclude("mach/vm_region.h");
});

In another file I used it like this const c = @import("c.zig");.
This is my build.zig file.

const std = @import("std");

const targets: []const std.Target.Query = &.{
    .{ .cpu_arch = .aarch64, .os_tag = .macos },
    .{ .cpu_arch = .x86_64, .os_tag = .macos },
};

pub fn build(b: *std.Build) void {
    for (targets) |t| {
        const exe = b.addExecutable(.{
            .name = "G-MemZ",
            .root_source_file = b.path("src/main.zig"),
            .target = b.resolveTargetQuery(t),
            .optimize = .ReleaseSmall,
        });

        const target_output = b.addInstallArtifact(exe, .{
            .dest_dir = .{
                .override = .{
                    .custom = t.zigTriple(b.allocator) catch "unknown",
                },
            },
        });

        b.getInstallStep().dependOn(&target_output.step);
    }
}

However it is unable to find the include mach/mach-vm.h.
What would be the simplest way to solve this?

hidden latch
#

it doesnt look like youre adding exe.addIncludePath anywhere, also is mach/mach-vm.h vs mach/mach_vm.h just a typo