Преглед изворни кода

build: use our own main() wrapper in addition to SDL's, and only

in that case. Currently only works with GCC.
legacy
Sam Hocevar sam пре 12 година
родитељ
комит
96256f45ce
4 измењених фајлова са 41 додато и 4 уклоњено
  1. +2
    -1
      configure.ac
  2. +7
    -2
      src/core.h
  3. +31
    -0
      src/platform/sdl/sdlapp.cpp
  4. +1
    -1
      test/math/Makefile.am

+ 2
- 1
configure.ac Прегледај датотеку

@@ -197,7 +197,8 @@ AC_MSG_CHECKING(for -mwindows -mwin32)
AC_TRY_LINK([], [],
[AC_MSG_RESULT(yes)
CXXFLAGS="${CXXFLAGS} -mwindows -mwin32"
LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16"],
dnl If we come across these symbols, try to link them
LOL_LIBS="${LOL_LIBS} -uWinMain -u_WinMain@16 -u_SDL_main"],
[AC_MSG_RESULT(no)])
LIBS="$LIBS_save"



+ 7
- 2
src/core.h Прегледај датотеку

@@ -68,9 +68,14 @@ static inline int isnan(float f)
# define main lol_android_main
#endif

/* If using SDL on Windows or OS X, let it override main() */
#if defined USE_SDL && (defined _WIN32 || defined __APPLE__)
/* If using SDL, let it override main() but immediately replace
* the override with ours. */
#if defined USE_SDL
# include <SDL_main.h>
# if defined main && !LOL_DONT_DIVERT_MAIN
# undef main
# define main lol_sdl_main
# endif
#endif

// Base types


+ 31
- 0
src/platform/sdl/sdlapp.cpp Прегледај датотеку

@@ -12,6 +12,10 @@
# include "config.h"
#endif

/* This instructs our headers to let SDL override the "main"
* symbol using its macros. */
#define LOL_DONT_DIVERT_MAIN 1

#if defined USE_SDL
# if defined HAVE_SDL_SDL_H
# include <SDL/SDL.h>
@@ -37,6 +41,33 @@ HWND g_hwnd = NULL;
extern IDirect3DDevice9 *g_d3ddevice;
#endif

#if defined main
# if defined _MSC_VER
# pragma comment(linker, "/alternatename:_lol_sdl_main=_lol_sdl_main_msvc")
# define WRAPPER lol_sdl_main_msvc
# else
int lol_sdl_main() __attribute__((weak));
int lol_sdl_main(int argc, char **argv) __attribute__((weak));
int lol_sdl_main(int argc, char **argv, char **envp) __attribute__((weak));
# define WRAPPER lol_sdl_main
# 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);
ret += lol_sdl_main(argc, argv, NULL);
return ret;
}
#endif

namespace lol
{



+ 1
- 1
test/math/Makefile.am Прегледај датотеку

@@ -9,7 +9,7 @@ noinst_PROGRAMS = pi poly remez

pi_SOURCES = pi.cpp
pi_CPPFLAGS = @LOL_CFLAGS@
pi_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@
pi_LDFLAGS = -u_SDL_main -uSDL_main $(top_builddir)/src/liblol.a @LOL_LIBS@
pi_DEPENDENCIES = $(top_builddir)/src/liblol.a

poly_SOURCES = poly.cpp


Loading…
Откажи
Сачувај