1 #if defined(_WIN32) || defined(WIN32) 2 # define DLL_EXPORT __declspec(dllexport) 3 # define DLL_IMPORT __declspec(dllimport) 4 #else 5 # define DLL_EXPORT __attribute__((visibility("default"))) 6 # define DLL_IMPORT __attribute__((visibility("default"))) 7 # endif 8 9 #ifdef MYLIB_BUILD 10 #define MYLIB_EXPORT DLL_EXPORT 11 #else 12 #define MYLIB_EXPORT DLL_IMPORT 13 #endif 14 15 namespace MyLib { 16 MYLIB_EXPORT void f(); 17 } 18