Changeset 2273


Ignore:
Timestamp:
Jan 25, 2013, 12:38:58 PM (7 years ago)
Author:
sam
Message:

build: use our own main() wrapper in addition to SDL's, and only
in that case. Currently only works with GCC.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r2263 r2273  
    198198 [AC_MSG_RESULT(yes)
    199199  CXXFLAGS="${CXXFLAGS} -mwindows -mwin32"
    200   LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
     200  dnl  If we come across these symbols, try to link them
     201  LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16 -u_SDL_main"],
    201202 [AC_MSG_RESULT(no)])
    202203LIBS="$LIBS_save"
  • trunk/src/core.h

    r2265 r2273  
    6969#endif
    7070
    71 /* If using SDL on Windows or OS X, let it override main() */
    72 #if defined USE_SDL && (defined _WIN32 || defined __APPLE__)
     71/* If using SDL, let it override main() but immediately replace
     72 * the override with ours. */
     73#if defined USE_SDL
    7374#   include <SDL_main.h>
     75#   if defined main && !LOL_DONT_DIVERT_MAIN
     76#       undef main
     77#       define main lol_sdl_main
     78#   endif
    7479#endif
    7580
  • trunk/src/platform/sdl/sdlapp.cpp

    r2222 r2273  
    1212#   include "config.h"
    1313#endif
     14
     15/* This instructs our headers to let SDL override the "main"
     16 * symbol using its macros. */
     17#define LOL_DONT_DIVERT_MAIN 1
    1418
    1519#if defined USE_SDL
     
    3640HWND g_hwnd = NULL;
    3741extern IDirect3DDevice9 *g_d3ddevice;
     42#endif
     43
     44#if defined main
     45#   if defined _MSC_VER
     46#       pragma comment(linker, "/alternatename:_lol_sdl_main=_lol_sdl_main_msvc")
     47#       define WRAPPER lol_sdl_main_msvc
     48#   else
     49int lol_sdl_main() __attribute__((weak));
     50int lol_sdl_main(int argc, char **argv) __attribute__((weak));
     51int lol_sdl_main(int argc, char **argv, char **envp) __attribute__((weak));
     52#       define WRAPPER lol_sdl_main
     53#   endif
     54
     55/* One of these wrappers will be overridden by the user's version */
     56int WRAPPER() { return 0; }
     57int WRAPPER(int argc, char **argv) { return 0; }
     58int WRAPPER(int argc, char **argv, char **envp) { return 0; }
     59
     60int main(int argc, char *argv[])
     61{
     62printf("LOL OK\n");
     63    int ret = 0;
     64    ret += lol_sdl_main();
     65    ret += lol_sdl_main(argc, argv);
     66    ret += lol_sdl_main(argc, argv, NULL);
     67    return ret;
     68}
    3869#endif
    3970
  • trunk/test/math/Makefile.am

    r2084 r2273  
    1010pi_SOURCES = pi.cpp
    1111pi_CPPFLAGS = @LOL_CFLAGS@
    12 pi_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@
     12pi_LDFLAGS = -u_SDL_main -uSDL_main $(top_builddir)/src/liblol.a @LOL_LIBS@
    1313pi_DEPENDENCIES = $(top_builddir)/src/liblol.a
    1414
Note: See TracChangeset for help on using the changeset viewer.