diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fbc7c8..c4d0974 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,9 +138,10 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_definitions(-fno-strict-aliasing) CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility) - if (cxx_has_fvisibility) - add_definitions(-fvisibility=hidden) + if (NOT cxx_has_fvisibility) + message(FATAL_ERROR "Compiler does not support -fvisibility") endif() + add_definitions(-fvisibility=hidden) # TODO fix these warnings add_definitions(-Wno-sign-compare) diff --git a/d3xp/Game.def b/d3xp/Game.def deleted file mode 100644 index 4461243..0000000 --- a/d3xp/Game.def +++ /dev/null @@ -1,2 +0,0 @@ -EXPORTS - GetGameAPI diff --git a/d3xp/Game_local.cpp b/d3xp/Game_local.cpp index 077ddb2..cd36bdf 100644 --- a/d3xp/Game_local.cpp +++ b/d3xp/Game_local.cpp @@ -134,10 +134,7 @@ static const char* fastEntityList[] = { GetGameAPI ============ */ -#if __GNUC__ >= 4 -#pragma GCC visibility push(default) -#endif -extern "C" gameExport_t *GetGameAPI( gameImport_t *import ) { +extern "C" ID_GAME_API gameExport_t *GetGameAPI( gameImport_t *import ) { if ( import->version == GAME_API_VERSION ) { @@ -170,9 +167,6 @@ extern "C" gameExport_t *GetGameAPI( gameImport_t *import ) { return &gameExport; } -#if __GNUC__ >= 4 -#pragma GCC visibility pop -#endif /* =========== diff --git a/game/Game.def b/game/Game.def deleted file mode 100644 index 38f6f29..0000000 --- a/game/Game.def +++ /dev/null @@ -1 +0,0 @@ -EXPORTS GetGameAPI diff --git a/game/Game_local.cpp b/game/Game_local.cpp index 20fddb7..3b99f75 100644 --- a/game/Game_local.cpp +++ b/game/Game_local.cpp @@ -98,11 +98,7 @@ const char *idGameLocal::sufaceTypeNames[ MAX_SURFACE_TYPES ] = { GetGameAPI ============ */ -#if __GNUC__ >= 4 -#pragma GCC visibility push(default) -#endif -extern "C" gameExport_t *GetGameAPI( gameImport_t *import ) { - +extern "C" ID_GAME_API gameExport_t *GetGameAPI( gameImport_t *import ) { if ( import->version == GAME_API_VERSION ) { // set interface pointers used by the game @@ -134,9 +130,6 @@ extern "C" gameExport_t *GetGameAPI( gameImport_t *import ) { return &gameExport; } -#if __GNUC__ >= 4 -#pragma GCC visibility pop -#endif /* =========== diff --git a/sys/platform.h b/sys/platform.h index 6bab71b..a95a8ba 100644 --- a/sys/platform.h +++ b/sys/platform.h @@ -53,12 +53,22 @@ If you have questions concerning this license or the applicable additional terms #define PATHSEPERATOR_CHAR '\\' #ifdef _MSC_VER +#ifdef GAME_DLL +#define ID_GAME_API __declspec(dllexport) +#else +#define ID_GAME_API +#endif #define ALIGN16( x ) __declspec(align(16)) x #define PACKED #define ID_INLINE __forceinline #define ID_STATIC_TEMPLATE static #define assertmem( x, y ) assert( _CrtIsValidPointer( x, y, true ) ) #else +#ifdef GAME_DLL +#define ID_GAME_API __attribute__((visibility ("default"))) +#else +#define ID_GAME_API +#endif #define ALIGN16( x ) x __attribute__ ((aligned (16))) #define PACKED __attribute__((packed)) #define ID_INLINE inline @@ -82,6 +92,12 @@ If you have questions concerning this license or the applicable additional terms #define CPU_EASYARGS 1 #endif +#ifdef GAME_DLL +#define ID_GAME_API __attribute__((visibility ("default"))) +#else +#define ID_GAME_API +#endif + #define ALIGN16( x ) x __attribute__ ((aligned (16))) #define PACKED __attribute__((packed)) @@ -140,6 +156,12 @@ If you have questions concerning this license or the applicable additional terms #define _alloca alloca #define _alloca16( x ) ((void *)((((uintptr_t)alloca( (x)+15 )) + 15) & ~15)) +#ifdef GAME_DLL +#define ID_GAME_API __attribute__((visibility ("default"))) +#else +#define ID_GAME_API +#endif + #define ALIGN16( x ) x #define PACKED __attribute__((packed))