diff --git a/SConstruct b/SConstruct index c91f569f2d..e409bde916 100644 --- a/SConstruct +++ b/SConstruct @@ -22,6 +22,9 @@ compileFlags = [ '-msse2', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', + '-DGCC_HASCLASSVISIBILITY', + '-fvisibility=hidden', + '-fvisibility-inlines-hidden', ] compileFlags += [ '-W' + warning for warning in warnings ] #compileFlags += [ '-DLOGGING' ] diff --git a/Source/PluginSpecs/ExportEpilog.h b/Source/PluginSpecs/ExportEpilog.h new file mode 100644 index 0000000000..d3a9387023 --- /dev/null +++ b/Source/PluginSpecs/ExportEpilog.h @@ -0,0 +1,6 @@ +#undef EXPORT +#undef CALL + +#if defined(__cplusplus) +} +#endif diff --git a/Source/PluginSpecs/ExportProlog.h b/Source/PluginSpecs/ExportProlog.h new file mode 100644 index 0000000000..803f354742 --- /dev/null +++ b/Source/PluginSpecs/ExportProlog.h @@ -0,0 +1,15 @@ +#ifdef _WIN32 + +#define EXPORT __declspec(dllexport) +#define CALL __cdecl + +#else + +#define EXPORT __attribute__ ((visibility("default"))) +#define CALL + +#endif + +#if defined(__cplusplus) +extern "C" { +#endif diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index 8160a833cb..0d7540a8c8 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -2,6 +2,14 @@ // Common plugin spec, version #1.0 maintained by F|RES // +#ifdef _WIN32 +#define EXPORT __declspec(dllexport) +#define CALL __cdecl +#else +#define EXPORT __attribute__ ((visibility("default"))) +#define CALL +#endif + #ifndef _PLUGINS_H_INCLUDED__ #define _PLUGINS_H_INCLUDED__ @@ -11,9 +19,6 @@ #else -#define EXPORT -#define CALL - #ifndef TRUE #define TRUE 1 #define FALSE 0 diff --git a/Source/PluginSpecs/pluginspecs_compiler.h b/Source/PluginSpecs/pluginspecs_compiler.h index 5b0ec476a9..730957057f 100644 --- a/Source/PluginSpecs/pluginspecs_compiler.h +++ b/Source/PluginSpecs/pluginspecs_compiler.h @@ -7,12 +7,7 @@ #include "PluginSpecs.h" -#if defined(__cplusplus) -extern "C" { -#endif - -#define EXPORT __declspec(dllexport) -#define CALL _cdecl +#include "ExportProlog.h" typedef void (*TWriteBigEData)(const unsigned __int8* _pData, const unsigned __int32 _iAddress, const unsigned __int32 _iSize); typedef void (*TPatchFunction)(DWORD _uAddress, unsigned char* _pMachineCode); @@ -99,7 +94,5 @@ EXPORT DWORD CALL CompileSourceCode(char* _szSourceCode, BYTE* _pMachineCode, DW // EXPORT DWORD CALL InsertEventString(char* _szEventSourceCode); -#if defined(__cplusplus) -} -#endif +#include "ExportEpilog.h" #endif diff --git a/Source/PluginSpecs/pluginspecs_dsp.h b/Source/PluginSpecs/pluginspecs_dsp.h index a6fa868860..05005ef6a3 100644 --- a/Source/PluginSpecs/pluginspecs_dsp.h +++ b/Source/PluginSpecs/pluginspecs_dsp.h @@ -7,17 +7,7 @@ #include "PluginSpecs.h" -#if defined(__cplusplus) -extern "C" { -#endif - -#ifdef _WIN32 -#define EXPORT __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT -#define CALL -#endif +#include "ExportProlog.h" typedef unsigned char (*TARAM_Read_U8)(const unsigned int _uAddress); typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _uAddress); @@ -163,8 +153,6 @@ EXPORT void CALL DSP_Update(int cycles); // input: _Size : Size of the Buffer (always 32) // EXPORT void CALL DSP_SendAIBuffer(unsigned int address, int sample_rate); - #undef CALL -#if defined(__cplusplus) -} -#endif + +#include "ExportEpilog.h" #endif diff --git a/Source/PluginSpecs/pluginspecs_pad.h b/Source/PluginSpecs/pluginspecs_pad.h index 1ebaeae406..a195e023f3 100644 --- a/Source/PluginSpecs/pluginspecs_pad.h +++ b/Source/PluginSpecs/pluginspecs_pad.h @@ -7,17 +7,7 @@ #include "PluginSpecs.h" -#if defined(__cplusplus) -extern "C" { -#endif - -#ifdef _WIN32 -#define EXPORT __declspec(dllexport) -#define CALL __cdecl -#else -#define CALL -#define EXPORT -#endif +#include "ExportProlog.h" #define PAD_ERR_NONE 0 #define PAD_ERR_NO_CONTROLLER -1 @@ -142,8 +132,6 @@ EXPORT unsigned int CALL PAD_GetAttachedPads(); // states don't become plugin dependent which would suck // EXPORT unsigned int CALL SaveLoadState(char *ptr, BOOL save); -#undef CALL -#if defined(__cplusplus) -} -#endif + +#include "ExportEpilog.h" #endif diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index cb139f6a59..fdcefdc9dc 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -7,17 +7,7 @@ #include "PluginSpecs.h" -#if defined(__cplusplus) -extern "C" { -#endif - -#ifdef _WIN32 -#define EXPORT __declspec(dllexport) -#define CALL __cdecl -#else -#define EXPORT -#define CALL -#endif +#include "ExportProlog.h" typedef void (*TSetPEToken)(const unsigned short _token, const int _bSetTokenAcknowledge); typedef void (*TSetPEFinish)(void); @@ -193,9 +183,5 @@ EXPORT void CALL Video_SaveState(); // EXPORT void CALL Video_LoadState(); -#undef CALL - -#if defined(__cplusplus) -} -#endif +#include "ExportEpilog.h" #endif