From: Claudio Jeker Subject: colobot fix for gcc15 To: "Anthony J. Bentley" Cc: ports@openbsd.org Date: Tue, 16 Dec 2025 11:10:32 +0100 Backport https://github.com/colobot/colobot/commit/1561854b03500d39955c66971c9c98de1937d7e6 Check if SDL_main is in use The main() function of colobot-app is declared as extern "C" to prevent name mangling. This is required because on some platforms, SDL2 declares its own main() function and defines a macro that renames the user's main to SDL_main; in which case, name mangling may cause linking failures. However, when building for platforms where this is not the case, gcc15 complains that specifying linkage for main is not allowed. > error: cannot declare ‘::main’ with a linkage > specification [-Wpedantic] This commit wraps the extern block in #ifdefs that check if the main -> SDL_main macro is in use. Fixes sparc64 compile. -- :wq Claudio Index: colobot/patches/patch-src_app_main_cpp =================================================================== RCS file: colobot/patches/patch-src_app_main_cpp diff -N colobot/patches/patch-src_app_main_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ colobot/patches/patch-src_app_main_cpp 16 Dec 2025 09:35:34 -0000 @@ -0,0 +1,35 @@ +Backport of commit 1561854b03500d39955c66971c9c98de1937d7e6 + +gcc15 complains that specifying linkage for main is not allowed. +> error: cannot declare ‘::main’ with a linkage +> specification [-Wpedantic] + +This commit wraps the extern block in #ifdefs that check +if the main -> SDL_main macro is in use. + +Index: src/app/main.cpp +--- src/app/main.cpp.orig ++++ src/app/main.cpp +@@ -94,10 +94,14 @@ The current layout is the following: + - src/script - link with the CBot library + */ + +-//! Entry point to the program ++// On *some* platforms, SDL declares a macro which renames main to SDL_main. ++// If that's the case, use "extern C" to prevent name mangling. ++#ifdef main + extern "C" + { ++#endif + ++//! Entry point to the program + int main(int argc, char *argv[]) + { + CLogger logger; // single instance of logger +@@ -176,4 +180,6 @@ int main(int argc, char *argv[]) + return code; + } + ++#ifdef main + } // extern "C" ++#endif