26
是否存在用於從共享庫中顯式導出函數的Linux等效項__declspec(dllexport)
?出於某種原因,我正在使用工具鏈,不是類成員的函數不會出現在生成的共享庫文件中。在Linux中顯式導出共享庫函數
是否存在用於從共享庫中顯式導出函數的Linux等效項__declspec(dllexport)
?出於某種原因,我正在使用工具鏈,不是類成員的函數不會出現在生成的共享庫文件中。在Linux中顯式導出共享庫函數
__attribute__((visibility("default")))
據我所知,沒有相當於__declspec(dllimport)
。
#if defined(_MSC_VER)
// Microsoft
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
// GCC
#define EXPORT __attribute__((visibility("default")))
#define IMPORT
#else
// do nothing and hope for the best?
#define EXPORT
#define IMPORT
#pragma warning Unknown dynamic link import/export semantics.
#endif
http://gcc.gnu.org/wiki/Visibility
這是兩個MSVC和gcc導出一個完整的教程。
沒有預定義的_GCC宏,而是使用'__GNUC__'。 – 2016-06-11 23:44:17
有關放置宏的位置的說明對未來的讀者會很好。 – ManuelSchneid3r 2017-03-25 11:00:01