跨平台编译时控制dll导出的方式的写法

#if defined(_MSC_VER)
    //  Microsoft
    #ifdef EXPORTING_DLL
        #define EXPORT_DLL __declspec(dllexport)
    #else
        #define EXPORT_DLL __declspec(dllimport)
    #endif
#elif defined(__GNUC__)
    //  GCC
    #ifdef EXPORTING_DLL
        #define EXPORT_DLL __attribute__((visibility("default")))
    #else
        #define EXPORT_DLL
    #endif
#else
//  do nothing and hope for the best?
    #ifdef EXPORTING_DLL
        #define EXPORT_DLL
    #else
        #define EXPORT_DLL
    #endif
    #pragma warning Unknown dynamic link import/export semantics.
#endif

你可能感兴趣的:(跨平台编译时控制dll导出的方式的写法)