SDL2/src/main/windows/SDL_windows_main.c

9 lines
240 B
C
Raw Normal View History

/*
SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98
Nothing to do here, the code moved into SDL_main_impl.h and SDL_windows.c (SDL_RunApp())
Implement SDL_main as header-only lib for Win32 (remaining platforms will follow) SDL_main.h is *not* included by SDL.h anymore, users are supposed to include it directly now, usually only in the file they implement main() in. If they need the header elsewhere or don't want SDL_main to implement main() (but only call SDL_SetMainReady() or whatever), they can #define SDL_MAIN_HANDLED first, same as before. For SDL-internal usage, I added _SDL_MAIN_NOIMPL, which *also* skips the implementation and `#define main SDL_main`, but still defines SDL_MAIN_AVAILABLE and SDL_MAIN_NEEDED in SDL_main.h, as before. To make the implementaion in the header shorter and avoid including windows.h, I moved most of the Win32 SDL_main code into SDL3.dll via SDL_Win32RunApp(), so the header-only part is just the different main functions calling SDL_Win32RunApp(SDL_main, NULL) Note that I changed changed the return value and type of OutOfMemory() to return -1 instead of FALSE, so main() (or WinMain() or whatever) returns -1 instead of 0 in case of an out-of-memory error Compared to original Win32 SDL_main, I tweaked the part of the implementation in SDL_main_impl.h a bit to avoid linker warnings and conflicts with stuff from windows.h: - replaced windows.h with own define of WINAPI and typedef-ing HINSTANCE and LPSTR. This prevents conflicts between all the generically-named #defines and types in windows.h and user code (like DrawState in some SDL tests) - only using one of main() or wmain() gets rid of a MSVC linker error ("warning LNK4067: ambiguous entry point") If this still causes problems, we might try getting rid of wmain(), seemed to me like MSVC can use regular main() in UNICODE mode as well - simplified the UNICODE logic for that - while this is not exactly equivalent to the old, it should make sense and Works For Me
2022-12-03 20:29:22 -06:00
TODO: remove this file
*/
/* vi: set ts=4 sw=4 expandtab: */