@@ -69,12 +69,27 @@ static inline int isnan(float f) | |||||
#endif | #endif | ||||
/* If using SDL, let it override main() but immediately replace | /* 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 | #if defined USE_SDL | ||||
# include <SDL_main.h> | # include <SDL_main.h> | ||||
# if defined main && !LOL_DONT_DIVERT_MAIN | # if defined main && !LOL_DONT_DIVERT_MAIN | ||||
# undef main | # undef main | ||||
# define main lol_sdl_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 | ||||
#endif | #endif | ||||
@@ -43,7 +43,9 @@ extern IDirect3DDevice9 *g_d3ddevice; | |||||
#if defined main | #if defined main | ||||
# if defined _MSC_VER | # 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 | # define WRAPPER lol_sdl_main_msvc | ||||
# else | # else | ||||
int lol_sdl_main() __attribute__((weak)); | int lol_sdl_main() __attribute__((weak)); | ||||
@@ -53,13 +55,13 @@ int lol_sdl_main(int argc, char **argv, char **envp) __attribute__((weak)); | |||||
# endif | # endif | ||||
/* One of these wrappers will be overridden by the user's version */ | /* One of these wrappers will be overridden by the user's version */ | ||||
int WRAPPER() { return 0; } | int WRAPPER() { return 0; } | ||||
int WRAPPER(int argc, char **argv) { return 0; } | int WRAPPER(int argc, char **argv) { return 0; } | ||||
int WRAPPER(int argc, char **argv, char **envp) { return 0; } | int WRAPPER(int argc, char **argv, char **envp) { return 0; } | ||||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
{ | { | ||||
printf("LOL OK\n"); | |||||
int ret = 0; | int ret = 0; | ||||
ret += lol_sdl_main(); | ret += lol_sdl_main(); | ||||
ret += lol_sdl_main(argc, argv); | ret += lol_sdl_main(argc, argv); | ||||
@@ -19,7 +19,7 @@ | |||||
#include <lol/unit.h> | #include <lol/unit.h> | ||||
int main(int argc, char **argv) | |||||
int main() | |||||
{ | { | ||||
lol::TextTestRunner runner; | lol::TextTestRunner runner; | ||||
bool success = runner.Run(); | bool success = runner.Run(); | ||||