Skip to content

Instantly share code, notes, and snippets.

@emekoi
Last active May 25, 2019 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emekoi/7b2b502f3536ebc36e1282f9a8e9c545 to your computer and use it in GitHub Desktop.
Save emekoi/7b2b502f3536ebc36e1282f9a8e9c545 to your computer and use it in GitHub Desktop.
zig winmain error
// runs WinMain using this WinMainCRTStartup
const HANDLE = *c_void;
const LPCTSTR = [*c]const u8;
const UINT = c_uint;
const HINSTANCE = ?*@OpaqueType();
const HMODULE = ?*@OpaqueType();
const PWSTR = [*c]u16;
const INT = c_int;
extern "kernel32" stdcallcc fn GetModuleHandleA(lpModuleName: ?[*]const u8) HINSTANCE;
extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;
pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
export stdcallcc fn WinMain(hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: PWSTR, nCmdShow: INT) UINT {
_ = MessageBoxA(null, c"hello", c"title", 0);
return 0;
}
export fn WinMainCRTStartup() noreturn {
@setAlignStack(16);
const result = WinMain(GetModuleHandleA(null), null, null, 0);
ExitProcess(result);
}
// error: exported symbol collision: 'WinMainCRTStartup'
// error: root source file has no member called 'main'
const HANDLE = *c_void;
const LPCTSTR = [*c]const u8;
const UINT = c_uint;
const HINSTANCE = ?*@OpaqueType();
const HMODULE = ?*@OpaqueType();
const PWSTR = [*c]u16;
const INT = c_int;
extern "kernel32" stdcallcc fn GetModuleHandleA(lpModuleName: ?[*]const u8) HINSTANCE;
extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;
pub extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
export stdcallcc fn WinMain(hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: PWSTR, nCmdShow: INT) UINT {
_ = MessageBoxA(null, c"hello", c"title", 0);
return 0;
}
export stdcallcc fn WinMainCRTStartup() noreturn {
@setAlignStack(16);
const result = WinMain(GetModuleHandleA(null), null, null, 0);
ExitProcess(result);
}
// runs WinMain using bootstrap.WinMainCRTStartup
const HANDLE = *c_void;
const LPCTSTR = [*]const u8;
const UINT = c_uint;
const HINSTANCE = *@OpaqueType();
const HMODULE = *@OpaqueType();
const PWSTR = [*]u16;
const INT = c_int;
extern "kernel32" stdcallcc fn GetModuleHandleA(lpModuleName: ?[*]const u8) HINSTANCE;
extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;
extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
export fn WinMain(hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?PWSTR, nCmdShow: INT) UINT {
_ = MessageBoxA(null, c"hello", c"title", 0);
return 0;
}
export fn WinMainCRTStartup() noreturn {
@setAlignStack(16);
const result = WinMain(GetModuleHandleA(null), null, null, 0);
ExitProcess(result);
}
// runs WinMain using bootstrap.WinMainCRTStartup
const HANDLE = *c_void;
const LPCTSTR = [*]const u8;
const UINT = c_uint;
const HINSTANCE = *@OpaqueType();
const HMODULE = *@OpaqueType();
const PWSTR = [*]u16;
const INT = c_int;
extern "kernel32" stdcallcc fn GetModuleHandleA(lpModuleName: ?[*]const u8) HINSTANCE;
extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;
extern "kernel32" stdcallcc fn ExitProcess(exit_code: UINT) noreturn;
export fn WinMain(hInstance: ?HINSTANCE, hPrevInstance: ?HINSTANCE, lpCmdLine: ?PWSTR, nCmdShow: INT) UINT {
_ = MessageBoxA(null, c"hello", c"title", 0);
return 0;
}
export stdcallcc fn WinMainCRTStartup() noreturn {
@setAlignStack(16);
const result = WinMain(GetModuleHandleA(null), null, null, 0);
ExitProcess(result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment