Skip to content

Commit

Permalink
Allow to have both WinMain and main defined on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Querijn committed Dec 11, 2024
1 parent a94f66a commit caada22
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
Optionally provide the following defines with your own implementations:
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
SOKOL_WIN32_FORCE_MAIN - define this on Win32 to use a main() entry point instead of WinMain
SOKOL_NO_ENTRY - define this if sokol_app.h shouldn't "hijack" the main() function
SOKOL_APP_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_DECL - same as SOKOL_APP_API_DECL
SOKOL_API_IMPL - public function implementation prefix (default: -)
SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false))
SOKOL_WIN32_FORCE_MAIN - define this on Win32 to add a main() entry point
SOKOL_WIN32_FORCE_WINMAIN - define this on Win32 to add a WinMain() entry point (enabled by default unless SOKOL_WIN32_FORCE_MAIN or SOKOL_NO_ENTRY is defined)
SOKOL_NO_ENTRY - define this if sokol_app.h shouldn't "hijack" the main() function
SOKOL_APP_API_DECL - public function declaration prefix (default: extern)
SOKOL_API_DECL - same as SOKOL_APP_API_DECL
SOKOL_API_IMPL - public function implementation prefix (default: -)
Optionally define the following to force debug checks and validations
even in release mode:
Expand Down Expand Up @@ -8155,7 +8156,8 @@ int main(int argc, char* argv[]) {
_sapp_win32_run(&desc);
return 0;
}
#else
#endif /* SOKOL_WIN32_FORCE_MAIN */
#if defined(SOKOL_WIN32_FORCE_WINMAIN) || !defined(SOKOL_WIN32_FORCE_MAIN)
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
_SOKOL_UNUSED(hInstance);
_SOKOL_UNUSED(hPrevInstance);
Expand All @@ -8168,7 +8170,7 @@ int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _
_sapp_free(argv_utf8);
return 0;
}
#endif /* SOKOL_WIN32_FORCE_MAIN */
#endif /* SOKOL_WIN32_FORCE_WINMAIN */
#endif /* SOKOL_NO_ENTRY */

#ifdef _MSC_VER
Expand Down

0 comments on commit caada22

Please sign in to comment.