diff --git a/src/Compilation.zig b/src/Compilation.zig index 232c3d32a6d3..7a84848b80b2 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -5205,22 +5205,21 @@ pub fn addCCArgs( } else if (target.isMinGW()) { try argv.append("-D__MSVCRT_VERSION__=0xE00"); // use ucrt + switch (ext) { + .c, .cpp, .m, .mm, .h, .hpp, .hm, .hmm, .cu, .rc, .assembly, .assembly_with_cpp => { + const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16); + try argv.append( + try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), + ); + }, + else => {}, + } } } 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, .hpp, .hm, .hmm, .cu, .rc, .assembly, .assembly_with_cpp => { - const minver: u16 = @truncate(@intFromEnum(target.os.getVersionRange().windows.min) >> 16); - try argv.append( - try std.fmt.allocPrint(arena, "-D_WIN32_WINNT=0x{x:0>4}", .{minver}), - ); - }, - else => {}, - }; - switch (ext) { .c, .cpp, .m, .mm, .h, .hpp, .hm, .hmm, .cu, .rc => { try argv.appendSlice(&[_][]const u8{ diff --git a/src/mingw.zig b/src/mingw.zig index f916b776ba15..ce15af3267bd 100644 --- a/src/mingw.zig +++ b/src/mingw.zig @@ -152,6 +152,7 @@ fn add_cc_args( "-D_CRTBLD", "-D_SYSCRT=1", "-DCRTDLL=1", + "-D_WIN32_WINNT=0x0f00", // According to Martin Storsjö, // > the files under mingw-w64-crt are designed to always // be built with __MSVCRT_VERSION__=0x700