Skip to content

Commit

Permalink
mingw: define _WIN32_WINNT when building CRT
Browse files Browse the repository at this point in the history
  • Loading branch information
ypsvlq authored and andrewrk committed Mar 20, 2024
1 parent e4ed63f commit 19b6995
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions src/mingw.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19b6995

Please sign in to comment.