Open PeterBowman opened 6 years ago
If SDL_MAIN_HANDLED
is not defined, SDL2 redefines main
as SDL_main
so that it's handled internally (CLI parsing and so on). Compilations errors are expected if the main entry point is not given the full, standard signature (e.g. int main(void)
instead of int main(int argc, char ** argv)
). I managed to overcome that via https://github.com/asrob-uc3m/robotDevastation/commit/edf35f487401be4198292c3354734e572ab76508, but tests are failing now with SDL not found
.
The game starts successfully if I use add_executable(robotDevastation WIN32 ...)
. However, no input/output is allowed through the console since it's now a pure windowed application.
Per https://stackoverflow.com/a/11976179/10404307:
SDL requires initialization, so it injects its own main function that runs its initialization before calling your "main" function, which it renames to SDL_main so that it does not conflict with the actual main function.
As Captain Obvious said in the comment section, this is a massive pain in the patooty. I'd like to check why SDL fails to initialize before closing this as invalid (no action needed). Probably unrelated, but SDL_SetMainReady()
is mentioned here.
Moar links:
We need to define a
SDL_MAIN_HANDLED
on executable targets in order to make them work on Windows: https://github.com/asrob-uc3m/robotDevastation/commit/9e36c06061b7d4da9b8a3d8ebf9038904f3649cf. I just found today this answer in the CMake FAQ that could render useful here: theWIN32_EXECUTABLE
property target which can be set throughadd_executable(<name> WIN32 ...)
(docs).