authorgravatar for rohlemF@gmail.comRohlem <rohlemF@gmail.com> 2020-12-17 15:55:05+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-11 17:48:17-07:00
log4b280ac7e9730a30cb3a03350711a13cf45c5dfc
tree1ebea2209836695a8240ff595a9e8eaf66189b5b
parent2922a483099a0a45d4cbaf2bc7c3b43fcebe4e77

add std.zig.system.windows version check utility functions


1 files changed, 16 insertions(+), 0 deletions(-)

lib/std/zig/system/windows.zig+16
......@@ -43,3 +43,19 @@ pub fn detectRuntimeVersion() WindowsVersion {
4343
4444 return @intToEnum(WindowsVersion, version);
4545}
46
47/// Returns whether the target os versions are uniformly at least as new as the argument:
48/// true/false if this holds for the entire target range, null if it only holds for some.
49pub fn targetVersionIsAtLeast(requested_version: WindowsVersion) ?bool {
50 const requested = @enumToInt(requested_version);
51 const version_range = std.builtin.os.version_range.windows;
52 const target_min = @enumToInt(version_range.min);
53 const target_max = @enumToInt(version_range.max);
54 return if (target_max < requested) false else if (target_min >= requested) true else null;
55}
56
57/// Returns whether the runtime os version is at least as new as the argument.
58pub fn runtimeVersionIsAtLeast(requested_version: WindowsVersion) bool {
59 return targetVersionIsAtLeast(requested_version) orelse
60 (@enumToInt(detectRuntimeVersion()) >= @enumToInt(requested_version));
61}