union VersionRange [src]
The version ranges here represent the minimum OS version to be supported
and the maximum OS version to be supported. The default values represent
the range that the Zig Standard Library bases its abstractions on.
The minimum version of the range is the main setting to tweak for a target.
Usually, the maximum target OS version will remain the default, which is
the latest released version of the OS.
To test at compile time if the target is guaranteed to support a given OS feature,
one should check that the minimum version of the range is greater than or equal to
the version the feature was introduced in.
To test at compile time if the target certainly will not support a given OS feature,
one should check that the maximum version of the range is less than the version the
feature was introduced in.
If neither of these cases apply, a runtime check should be used to determine if the
target supports a given OS feature.
Binaries built with a given maximum version will continue to function on newer
operating system versions. However, such a binary may not take full advantage of the
newer operating system APIs.
See Os.isAtLeast.
Fields
none: void
semver: std.SemanticVersion.Range
hurd: HurdVersionRange
linux: LinuxVersionRange
windows: WindowsVersion.Range
Members
- default (Function)
Source
pub const VersionRange = union {
none: void,
semver: std.SemanticVersion.Range,
hurd: HurdVersionRange,
linux: LinuxVersionRange,
windows: WindowsVersion.Range,
/// The default `VersionRange` represents the range that the Zig Standard Library
/// bases its abstractions on.
pub fn default(arch: Cpu.Arch, tag: Tag, abi: Abi) VersionRange {
return switch (tag) {
.freestanding,
.other,
.elfiamcu,
.haiku,
.plan9,
.serenity,
.illumos,
.ps3,
.ps4,
.ps5,
.emscripten,
.mesa3d,
=> .{ .none = {} },
.contiki => .{
.semver = .{
.min = .{ .major = 4, .minor = 0, .patch = 0 },
.max = .{ .major = 5, .minor = 0, .patch = 0 },
},
},
.fuchsia => .{
.semver = .{
.min = .{ .major = 1, .minor = 1, .patch = 0 },
.max = .{ .major = 21, .minor = 1, .patch = 0 },
},
},
.hermit => .{
.semver = .{
.min = .{ .major = 0, .minor = 4, .patch = 0 },
.max = .{ .major = 0, .minor = 10, .patch = 0 },
},
},
.aix => .{
.semver = .{
.min = .{ .major = 7, .minor = 2, .patch = 5 },
.max = .{ .major = 7, .minor = 3, .patch = 2 },
},
},
.hurd => .{
.hurd = .{
.range = .{
.min = .{ .major = 0, .minor = 9, .patch = 0 },
.max = .{ .major = 0, .minor = 9, .patch = 0 },
},
.glibc = .{ .major = 2, .minor = 28, .patch = 0 },
},
},
.linux => .{
.linux = .{
.range = .{
.min = blk: {
const default_min: std.SemanticVersion = .{ .major = 4, .minor = 19, .patch = 0 };
for (std.zig.target.available_libcs) |libc| {
if (libc.arch != arch or libc.os != tag or libc.abi != abi) continue;
if (libc.os_ver) |min| {
if (min.order(default_min) == .gt) break :blk min;
}
}
break :blk default_min;
},
.max = .{ .major = 6, .minor = 13, .patch = 4 },
},
.glibc = blk: {
const default_min: std.SemanticVersion = .{ .major = 2, .minor = 28, .patch = 0 };
for (std.zig.target.available_libcs) |libc| {
if (libc.os != tag or libc.arch != arch or libc.abi != abi) continue;
if (libc.glibc_min) |min| {
if (min.order(default_min) == .gt) break :blk min;
}
}
break :blk default_min;
},
.android = 14,
},
},
.rtems => .{
.semver = .{
.min = .{ .major = 5, .minor = 1, .patch = 0 },
.max = .{ .major = 6, .minor = 1, .patch = 0 },
},
},
.zos => .{
.semver = .{
.min = .{ .major = 2, .minor = 5, .patch = 0 },
.max = .{ .major = 3, .minor = 1, .patch = 0 },
},
},
.dragonfly => .{
.semver = .{
.min = .{ .major = 5, .minor = 8, .patch = 0 },
.max = .{ .major = 6, .minor = 4, .patch = 0 },
},
},
.freebsd => .{
.semver = .{
.min = .{ .major = 12, .minor = 0, .patch = 0 },
.max = .{ .major = 14, .minor = 2, .patch = 0 },
},
},
.netbsd => .{
.semver = .{
.min = .{ .major = 8, .minor = 0, .patch = 0 },
.max = .{ .major = 10, .minor = 1, .patch = 0 },
},
},
.openbsd => .{
.semver = .{
.min = .{ .major = 7, .minor = 3, .patch = 0 },
.max = .{ .major = 7, .minor = 6, .patch = 0 },
},
},
.driverkit => .{
.semver = .{
.min = .{ .major = 19, .minor = 0, .patch = 0 },
.max = .{ .major = 24, .minor = 2, .patch = 0 },
},
},
.macos => .{
.semver = .{
.min = .{ .major = 13, .minor = 0, .patch = 0 },
.max = .{ .major = 15, .minor = 3, .patch = 1 },
},
},
.ios => .{
.semver = .{
.min = .{ .major = 12, .minor = 0, .patch = 0 },
.max = .{ .major = 18, .minor = 3, .patch = 1 },
},
},
.tvos => .{
.semver = .{
.min = .{ .major = 13, .minor = 0, .patch = 0 },
.max = .{ .major = 18, .minor = 3, .patch = 0 },
},
},
.visionos => .{
.semver = .{
.min = .{ .major = 1, .minor = 0, .patch = 0 },
.max = .{ .major = 2, .minor = 3, .patch = 1 },
},
},
.watchos => .{
.semver = .{
.min = .{ .major = 6, .minor = 0, .patch = 0 },
.max = .{ .major = 11, .minor = 3, .patch = 1 },
},
},
.solaris => .{
.semver = .{
.min = .{ .major = 11, .minor = 0, .patch = 0 },
.max = .{ .major = 11, .minor = 4, .patch = 0 },
},
},
.windows => .{
.windows = .{
.min = .win10,
.max = WindowsVersion.latest,
},
},
.uefi => .{
.semver = .{
.min = .{ .major = 2, .minor = 0, .patch = 0 },
.max = .{ .major = 2, .minor = 11, .patch = 0 },
},
},
.wasi => .{
.semver = .{
.min = .{ .major = 0, .minor = 1, .patch = 0 },
.max = .{ .major = 0, .minor = 2, .patch = 2 },
},
},
.amdhsa => .{
.semver = .{
.min = .{ .major = 5, .minor = 0, .patch = 2 },
.max = .{ .major = 6, .minor = 3, .patch = 0 },
},
},
.amdpal => .{
.semver = .{
.min = .{ .major = 1, .minor = 1, .patch = 0 },
.max = .{ .major = 3, .minor = 5, .patch = 0 },
},
},
.cuda => .{
.semver = .{
.min = .{ .major = 11, .minor = 0, .patch = 1 },
.max = .{ .major = 12, .minor = 8, .patch = 0 },
},
},
.nvcl,
.opencl,
=> .{
.semver = .{
.min = .{ .major = 2, .minor = 2, .patch = 0 },
.max = .{ .major = 3, .minor = 0, .patch = 17 },
},
},
.opengl => .{
.semver = .{
.min = .{ .major = 4, .minor = 5, .patch = 0 },
.max = .{ .major = 4, .minor = 6, .patch = 0 },
},
},
.vulkan => .{
.semver = .{
.min = .{ .major = 1, .minor = 2, .patch = 0 },
.max = .{ .major = 1, .minor = 4, .patch = 309 },
},
},
};
}
}