From 15ce9652525de2cc245203042d8c62ef30d5de1f Mon Sep 17 00:00:00 2001 From: Phil Richards Date: Tue, 26 Sep 2023 20:25:08 +0100 Subject: define `_WIN32_WINNT` for windows compilations based on target minver (#17224) --- src/Compilation.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 47d0125ffb..c1cfe4613c 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4880,6 +4880,14 @@ pub fn addCCArgs( const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target); try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple }); + if (target.os.tag == .windows) switch (ext) { + .c, .cpp, .m, .mm, .h, .cu, .rc, .assembly, .assembly_with_cpp => { + const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16); + try argv.append(try std.fmt.allocPrint(argv.allocator, "-D_WIN32_WINNT=0x{x:0>4}", .{minver})); + }, + else => {}, + }; + switch (ext) { .c, .cpp, .m, .mm, .h, .cu, .rc => { try argv.appendSlice(&[_][]const u8{ -- cgit v1.2.3