Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

findNativeMsvcIncludeDir

LibCInstallation.findNativeMsvcIncludeDir
fn findNativeMsvcIncludeDir(
    self: *LibCInstallation,
    gpa: Allocator,
    io: Io,
    sdk: std.zig.WindowsSdk,
) FindError!void

File

lib/std/zig/LibCInstallation.zig:521

Code

fn findNativeMsvcIncludeDir(
    self: *LibCInstallation,
    gpa: Allocator,
    io: Io,
    sdk: std.zig.WindowsSdk,
) FindError!void {
    const msvc_lib_dir = sdk.msvc_lib_dir orelse return error.LibCStdLibHeaderNotFound;
    const up1 = fs.path.dirname(msvc_lib_dir) orelse return error.LibCStdLibHeaderNotFound;
    const up2 = fs.path.dirname(up1) orelse return error.LibCStdLibHeaderNotFound;

    const dir_path = try fs.path.join(gpa, &[_][]const u8{ up2, "include" });
    errdefer gpa.free(dir_path);

    var dir = Io.Dir.cwd().openDir(io, dir_path, .{}) catch |err| switch (err) {
        error.FileNotFound,
        error.NotDir,
        error.NoDevice,
        => return error.LibCStdLibHeaderNotFound,

        else => return error.FileSystem,
    };
    defer dir.close(io);

    dir.access(io, "vcruntime.h", .{}) catch |err| switch (err) {
        error.FileNotFound => return error.LibCStdLibHeaderNotFound,
        else => return error.FileSystem,
    };

    self.sys_include_dir = dir_path;
}