Browse Source

build: provide weak symbols for lol_sdl_main on Visual Studio.

legacy
Sam Hocevar sam 12 years ago
parent
commit
d3af7653c0
3 changed files with 21 additions and 4 deletions
  1. +16
    -1
      src/core.h
  2. +4
    -2
      src/platform/sdl/sdlapp.cpp
  3. +1
    -1
      test/testsuite.cpp

+ 16
- 1
src/core.h View File

@@ -69,12 +69,27 @@ static inline int isnan(float f)
#endif

/* If using SDL, let it override main() but immediately replace
* the override with ours. */
* the override with ours, then declare weak symbols to ensure one
* of our dummy functions gets replaced by the user's main(). */
#if defined USE_SDL
# include <SDL_main.h>
# if defined main && !LOL_DONT_DIVERT_MAIN
# undef main
# define main lol_sdl_main
# if defined _MSC_VER
int lol_sdl_main();
int lol_sdl_main_msvc();
#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHXZ" \
"=?lol_sdl_main_msvc@@YAHXZ")
int lol_sdl_main(int argc, char **argv);
int lol_sdl_main_msvc(int argc, char **argv);
#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHHPEAPEAD@Z" \
"=?lol_sdl_main_msvc@@YAHHPEAPEAD@Z")
int lol_sdl_main(int argc, char **argv, char **envp);
int lol_sdl_main_msvc(int argc, char **argv, char **envp);
#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHHPEAPEAD0@Z" \
"=?lol_sdl_main_msvc@@YAHHPEAPEAD0@Z")
# endif
# endif
#endif



+ 4
- 2
src/platform/sdl/sdlapp.cpp View File

@@ -43,7 +43,9 @@ extern IDirect3DDevice9 *g_d3ddevice;

#if defined main
# if defined _MSC_VER
# pragma comment(linker, "/alternatename:_lol_sdl_main=_lol_sdl_main_msvc")
int lol_sdl_main();
int lol_sdl_main(int argc, char **argv);
int lol_sdl_main(int argc, char **argv, char **envp);
# define WRAPPER lol_sdl_main_msvc
# else
int lol_sdl_main() __attribute__((weak));
@@ -53,13 +55,13 @@ int lol_sdl_main(int argc, char **argv, char **envp) __attribute__((weak));
# endif

/* One of these wrappers will be overridden by the user's version */

int WRAPPER() { return 0; }
int WRAPPER(int argc, char **argv) { return 0; }
int WRAPPER(int argc, char **argv, char **envp) { return 0; }

int main(int argc, char *argv[])
{
printf("LOL OK\n");
int ret = 0;
ret += lol_sdl_main();
ret += lol_sdl_main(argc, argv);


+ 1
- 1
test/testsuite.cpp View File

@@ -19,7 +19,7 @@

#include <lol/unit.h>

int main(int argc, char **argv)
int main()
{
lol::TextTestRunner runner;
bool success = runner.Run();


Loading…
Cancel
Save