Commit d6e87da47b
Changed files (1)
lib
std
lib/std/start.zig
@@ -28,6 +28,8 @@ comptime {
if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
@export(main2, .{ .name = "main" });
}
+ } else if (builtin.stage2_os == .windows) {
+ @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" });
} else {
if (!@hasDecl(root, "_start")) {
@export(_start2, .{ .name = "_start" });
@@ -96,6 +98,11 @@ fn callMain2() noreturn {
exit2(0);
}
+fn wWinMainCRTStartup2() callconv(.C) noreturn {
+ root.main();
+ exit2(0);
+}
+
fn exit2(code: usize) noreturn {
switch (native_os) {
.linux => switch (builtin.stage2_arch) {
@@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn {
},
else => @compileError("TODO"),
},
+ .windows => {
+ ExitProcess(@truncate(u32, code));
+ },
else => @compileError("TODO"),
}
unreachable;
}
+extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn;
+
////////////////////////////////////////////////////////////////////////////////
fn _DllMainCRTStartup(