From 4df75645ce7d9f82b1b6fb5856c03bf145fabaa1 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Sat, 7 Nov 2020 10:44:05 -0700 Subject: [PATCH] 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. --- lib/std/start.zig | 7 ++++--- 1 file 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); }