Skip to content

Commit

Permalink
Fix a recursive call into main()
Browse files Browse the repository at this point in the history
When built as a shared library, the call from godot_main() ends up
calling the app's actual main, and hilarity ensues. Simple fix is
to define a common linux_main(), which is called by either godot_main()
or the real main() when built as an executable.
  • Loading branch information
pcbeard committed Jan 27, 2024
1 parent 05eb261 commit cc7181c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions platform/linuxbsd/godot_linuxbsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <sys/resource.h>
#endif

int main(int argc, char *argv[]) {
int linux_main(int argc, char *argv[]) {
#if defined(SANITIZERS_ENABLED)
// Note: Set stack size to be at least 30 MB (vs 8 MB default) to avoid overflow, address sanitizer can increase stack usage up to 3 times.
struct rlimit stack_lim = { 0x1E00000, 0x1E00000 };
Expand Down Expand Up @@ -88,6 +88,10 @@ int main(int argc, char *argv[]) {
#if defined(LIBRARY_ENABLED)
#include "core/libgodot/libgodot.h"
extern "C" LIBGODOT_API int godot_main(int argc, char *argv[]) {
return main(argc, argv);
return linux_main(argc, argv);
}
#else
int main(int argc, char *argv[]) {
return linux_main(argc, argv);
}
#endif

0 comments on commit cc7181c

Please sign in to comment.