mingw: define _WIN32_WINNT when building CRT

This commit is contained in:
Elaine Gibson
2024-03-18 12:47:15 +00:00
committed by Andrew Kelley
parent e4ed63f138
commit 19b6995939
2 changed files with 10 additions and 10 deletions

View File

@@ -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{

View File

@@ -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