aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
diff options
context:
space:
mode:
authorJonathan Marler <johnnymarler@gmail.com>2020-11-07 10:44:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-11-16 16:01:18 -0800
commit4df75645ce7d9f82b1b6fb5856c03bf145fabaa1 (patch)
treee3c1bf2cbd1369d73a4f9c69fe4f6f12ba015056 /lib/std/start.zig
parent48d60834fd61404ea009f7f970775f9c59de1240 (diff)
downloadzig-4df75645ce7d9f82b1b6fb5856c03bf145fabaa1.tar.gz
zig-4df75645ce7d9f82b1b6fb5856c03bf145fabaa1.zip
start.zig: call wWinMain with root's type
I have an alternative set of windows bindings I'm working on: https://github.com/marler8997/zig-os-windows. So I'm declaring my wWinMain function with my own HINSTANCE type rather than the one from std.os.windows. This change allows start to call wWinMain using any pointer type.
Diffstat (limited to 'lib/std/start.zig')
-rw-r--r--lib/std/start.zig7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index 8c416e44e2..aa03b3713a 100644
--- a/lib/std/start.zig
+++ b/lib/std/start.zig
@@ -354,13 +354,14 @@ pub fn callMain() u8 {
}
pub fn call_wWinMain() std.os.windows.INT {
- const hInstance = @ptrCast(std.os.windows.HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
- const hPrevInstance: ?std.os.windows.HINSTANCE = null; // MSDN: "This parameter is always NULL"
+ const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].arg_type.?;
+ const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
const lpCmdLine = std.os.windows.kernel32.GetCommandLineW();
// There's no (documented) way to get the nCmdShow parameter, so we're
// using this fairly standard default.
const nCmdShow = std.os.windows.user32.SW_SHOW;
- return root.wWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+ // second parameter hPrevInstance, MSDN: "This parameter is always NULL"
+ return root.wWinMain(hInstance, null, lpCmdLine, nCmdShow);
}