Here is a simplified version of what we use in our code.
#ifdef __cplusplus #define EXTERNC extern "C" #else #define EXTERNC #endif #if defined(__NT__) // MS Windows #define idaapi __stdcall #define ida_export idaapi #if defined(__IDP__) // modules #define idaman EXTERNC #else // kernel #if defined(__X64__) || defined(__NOEXPORT__) #define idaman EXTERNC #else #define idaman EXTERNC __declspec(dllexport) #endif #endif #define ida_local #elif defined(__UNIX__) // for unix #define idaapi #if defined(__MAC__) #define idaman EXTERNC __attribute__((visibility("default"))) #define ida_local __attribute__((visibility("hidden"))) #else // Linux #if __GNUC__ >= 4 #define idaman EXTERNC __attribute__ ((visibility("default"))) #define ida_local __attribute__((visibility("hidden"))) #else #define idaman EXTERNC #define ida_local #endif #endif #endif
On Linux / OS X, we compile all the default code with -fvisibility=hidden -fvisibility-inlines-hidden and mark the material we want to export with idaman , for example.
idaman bool ida_export set_enum_width(enum_t id, int width);
Since you export methods in C ++, you probably want to skip the extern "C" .
source share