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. Public Namespace

os

Public Namespace

Namespaces

Values

Functions

pub fn targetRequiresLibC(target: *const std.Target) bool

Returns whether the Zig standard library requires libc in order to interface with the operating system on the given target.

pub fn requiresLibC() bool

Returns whether the Zig standard library requires libc in order to interface with the operating system on the current target.

File

os.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const builtin = @import("builtin");
const std = @import("std.zig");
const native_os = builtin.os.tag;

pub const linux = @import("os/linux.zig");
pub const plan9 = @import("os/plan9.zig");
pub const uefi = @import("os/uefi.zig");
pub const wasi = @import("os/wasi.zig");
pub const emscripten = @import("os/emscripten.zig");
pub const windows = @import("os/windows.zig");

/// Returns whether the Zig standard library requires libc in order to interface
/// with the operating system on the given target.
pub fn targetRequiresLibC(target: *const std.Target) bool {
    if (target.requiresLibC()) return true;
    return switch (target.os.tag) {
        .linux => switch (target.cpu.arch) {
            // https://codeberg.org/ziglang/zig/issues/30943
            .hppa,
            .hppa64,
            => true,
            else => false,
        },
        .freebsd => true, // https://codeberg.org/ziglang/zig/issues/30981
        .netbsd => true, // https://codeberg.org/ziglang/zig/issues/30980
        .openbsd => true, // https://codeberg.org/ziglang/zig/issues/30982
        else => false,
    };
}

/// Returns whether the Zig standard library requires libc in order to interface
/// with the operating system on the current target.
pub fn requiresLibC() bool {
    return targetRequiresLibC(&builtin.target);
}

test {
    _ = linux;
    if (native_os == .uefi) _ = uefi;
    _ = wasi;
    _ = windows;
}