authorgravatar for phildrip@users.noreply.github.comPhil Richards <phildrip@users.noreply.github.com> 2023-09-26 20:25:08+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-09-26 15:25:08-04:00
log15ce9652525de2cc245203042d8c62ef30d5de1f
tree96d41cb813a1ee5e291a54bb2cf1b3a788866e96
parentf4c884617f499b52eaecc0ef674609c774052f8f
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

define `_WIN32_WINNT` for windows compilations based on target minver (#17224)


2 files changed, 8 insertions(+), 5 deletions(-)

src/Compilation.zig+8
......@@ -4880,6 +4880,14 @@ pub fn addCCArgs(
48804880 const llvm_triple = try @import("codegen/llvm.zig").targetTriple(arena, target);
48814881 try argv.appendSlice(&[_][]const u8{ "-target", llvm_triple });
48824882
4883 if (target.os.tag == .windows) switch (ext) {
4884 .c, .cpp, .m, .mm, .h, .cu, .rc, .assembly, .assembly_with_cpp => {
4885 const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16);
4886 try argv.append(try std.fmt.allocPrint(argv.allocator, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}));
4887 },
4888 else => {},
4889 };
4890
48834891 switch (ext) {
48844892 .c, .cpp, .m, .mm, .h, .cu, .rc => {
48854893 try argv.appendSlice(&[_][]const u8{
src/mingw.zig-5
......@@ -89,7 +89,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
8989
9090 "-std=gnu99",
9191 "-D_CRTBLD",
92 "-D_WIN32_WINNT=0x0f00",
9392 "-D__MSVCRT_VERSION__=0x700",
9493 "-D__USE_MINGW_ANSI_STDIO=0",
9594 });
......@@ -114,7 +113,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
114113
115114 "-std=gnu99",
116115 "-D_CRTBLD",
117 "-D_WIN32_WINNT=0x0f00",
118116 "-D__MSVCRT_VERSION__=0x700",
119117 "-D__USE_MINGW_ANSI_STDIO=0",
120118
......@@ -163,7 +161,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
163161
164162 "-std=gnu99",
165163 "-D_CRTBLD",
166 "-D_WIN32_WINNT=0x0f00",
167164 "-D__MSVCRT_VERSION__=0x700",
168165 "-D__USE_MINGW_ANSI_STDIO=0",
169166
......@@ -226,7 +223,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: *std.Progr
226223
227224 "-std=gnu99",
228225 "-D_CRTBLD",
229 "-D_WIN32_WINNT=0x0f00",
230226 "-D__MSVCRT_VERSION__=0x700",
231227 "-D__USE_MINGW_ANSI_STDIO=0",
232228
......@@ -272,7 +268,6 @@ fn add_cc_args(
272268 try args.appendSlice(&[_][]const u8{
273269 "-std=gnu11",
274270 "-D_CRTBLD",
275 "-D_WIN32_WINNT=0x0f00",
276271 "-D__MSVCRT_VERSION__=0x700",
277272 "-D__USE_MINGW_ANSI_STDIO=0",
278273 });