diff --git a/neo/sys/osx/DOOMController.mm b/neo/sys/osx/DOOMController.mm index 9da67edc..01e43586 100644 --- a/neo/sys/osx/DOOMController.mm +++ b/neo/sys/osx/DOOMController.mm @@ -32,9 +32,6 @@ If you have questions concerning this license or the applicable additional terms #include #include #include - -#include - #include "sys/platform.h" #include @@ -45,6 +42,11 @@ If you have questions concerning this license or the applicable additional terms #include "sys/posix/posix_public.h" +// usually the following would be from SDL_main.h, +// but this way we should be able to avoid that header +// for better compatibility between SDL1.2 to SDL3 +extern "C" int SDL_main( int argc, char *argv[] ); + static char base_path[MAXPATHLEN]; static char exe_path[MAXPATHLEN]; static char save_path[MAXPATHLEN]; @@ -194,13 +196,15 @@ int SDL_main( int argc, char *argv[] ) { Sys_Error("Could not access application resources"); // DG: set exe_path so Posix_InitSignalHandlers() can call Posix_GetExePath() - SDL_strlcpy(exe_path, [ [ [ NSBundle mainBundle ] bundlePath ] cStringUsingEncoding:NSUTF8StringEncoding ], sizeof(exe_path)); + strncpy(exe_path, [ [ [ NSBundle mainBundle ] bundlePath ] cStringUsingEncoding:NSUTF8StringEncoding ], sizeof(exe_path)-1); + exe_path[sizeof(exe_path)-1] = '\0'; // same for save_path for Posix_GetSavePath() D3_snprintfC99(save_path, sizeof(save_path), "%s/Library/Application Support/dhewm3", [NSHomeDirectory() cStringUsingEncoding:NSUTF8StringEncoding]); // and preinitializing basepath is easy enough so do that as well { char* snap; - SDL_strlcpy(base_path, exe_path, sizeof(base_path)); + strncpy(base_path, exe_path, sizeof(base_path)-1); + base_path[sizeof(base_path)-1] = '\0'; snap = strrchr(base_path, '/'); if (snap) *snap = '\0'; diff --git a/neo/sys/osx/SDLMain.m b/neo/sys/osx/SDLMain.m index ce6a7bd1..6a0aa612 100644 --- a/neo/sys/osx/SDLMain.m +++ b/neo/sys/osx/SDLMain.m @@ -10,7 +10,15 @@ #pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif -#include "SDL.h" +#ifdef D3_SDL3 + #include + // as SDL.h doesn't implicitly include SDL_main.h anymore, + // declare SDL_main() here. I think it's the only part of SDL_main.h we used, + // we implement it in DOOMController.mm an call it here in applicationDidFinishLaunching + extern "C" int SDL_main( int argc, char *argv[] ); +#else // SDL2 and SDL1.2 + #include "SDL.h" +#endif #include "SDLMain.h" #include /* for MAXPATHLEN */ #include