Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

findNativeCrtDirWindows

Private Function
std.zig.LibCInstallation.findNativeCrtDirWindows
fn findNativeCrtDirWindows(
    self: *LibCInstallation,
    gpa: Allocator,
    io: Io,
    target: *const std.Target,
    sdk: std.zig.WindowsSdk,
) FindError!void

Params

Errors

OutOfMemory
FileSystem
UnableToSpawnCCompiler
CCompilerExitCode
CCompilerCrashed
CCompilerCannotFindHeaders
LibCRuntimeNotFound
LibCStdLibHeaderNotFound
LibCKernel32LibNotFound
UnsupportedArchitecture
WindowsSdkNotFound
DarwinSdkNotFound
ZigIsTheCCompiler

File

zig/LibCInstallation.zig:411
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
fn findNativeCrtDirWindows(
    self: *LibCInstallation,
    gpa: Allocator,
    io: Io,
    target: *const std.Target,
    sdk: std.zig.WindowsSdk,
) FindError!void {
    var install_buf: [2]std.zig.WindowsSdk.Installation = undefined;
    const installs = fillInstallations(&install_buf, sdk);

    var result_buf = std.array_list.Managed(u8).init(gpa);
    defer result_buf.deinit();

    const arch_sub_dir = switch (target.cpu.arch) {
        .x86 => "x86",
        .x86_64 => "x64",
        .thumb => "arm",
        .aarch64 => "arm64",
        else => return error.UnsupportedArchitecture,
    };

    for (installs) |install| {
        result_buf.shrinkAndFree(0);
        try result_buf.print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ install.path, install.version, arch_sub_dir });

        var dir = Io.Dir.cwd().openDir(io, result_buf.items, .{}) catch |err| switch (err) {
            error.FileNotFound,
            error.NotDir,
            error.NoDevice,
            => continue,

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

        dir.access(io, "ucrt.lib", .{}) catch |err| switch (err) {
            error.FileNotFound => continue,
            else => return error.FileSystem,
        };

        self.crt_dir = try result_buf.toOwnedSlice();
        return;
    }
    return error.LibCRuntimeNotFound;
}