authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2020-11-07 10:44:05-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-16 16:01:18-08:00
log4df75645ce7d9f82b1b6fb5856c03bf145fabaa1
treee3c1bf2cbd1369d73a4f9c69fe4f6f12ba015056
parent48d60834fd61404ea009f7f970775f9c59de1240

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.

1 files changed, 4 insertions(+), 3 deletions(-)

lib/std/start.zig+4-3
......@@ -354,13 +354,14 @@ pub fn callMain() u8 {
354354}
355355
356356pub fn call_wWinMain() std.os.windows.INT {
357 const hInstance = @ptrCast(std.os.windows.HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
358 const hPrevInstance: ?std.os.windows.HINSTANCE = null; // MSDN: "This parameter is always NULL"
357 const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.args[0].arg_type.?;
358 const hInstance = @ptrCast(MAIN_HINSTANCE, std.os.windows.kernel32.GetModuleHandleW(null).?);
359359 const lpCmdLine = std.os.windows.kernel32.GetCommandLineW();
360360
361361 // There's no (documented) way to get the nCmdShow parameter, so we're
362362 // using this fairly standard default.
363363 const nCmdShow = std.os.windows.user32.SW_SHOW;
364364
365 return root.wWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
365 // second parameter hPrevInstance, MSDN: "This parameter is always NULL"
366 return root.wWinMain(hInstance, null, lpCmdLine, nCmdShow);
366367}