Re: [問題] Singleton 與 DLL

看板C_and_CPP (C/C++)作者 (acer)時間16年前 (2009/07/14 03:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《adxis (acer)》之銘言: 總算找出來到底是哪邊的問題了 => 忘了加上 define variable 0rzzzz 在VC上面,如果用了 _declspec(dllexport) 在使用 dll 的檔案 (client) 最好還是要 _declspec(dllimport) 也就是編譯 client 的時候記得下相對應的 define 參數 LokiExport.h 裡面是以 LOKI_MAKE_DLL 跟 LOKI_DLL 來區分 我則是偏好下面貼的方式 (出處 http://gcc.gnu.org/wiki/Visibility ) 不管編 lib 或是 client 都只要define DLL 即可 #ifndef _DLLEXPORT_H #define _DLLEXPORT_H // Generic helper definitions for shared library support #if defined WIN32 || defined __CYGWIN__ #define HELPER_DLL_IMPORT __declspec(dllimport) #define HELPER_DLL_EXPORT __declspec(dllexport) #define HELPER_DLL_LOCAL #else #if __GNUC__ >= 4 #define HELPER_DLL_IMPORT __attribute__ ((visibility("default"))) #define HELPER_DLL_EXPORT __attribute__ ((visibility("default"))) #define HELPER_DLL_LOCAL __attribute__ ((visibility("hidden"))) #else #define HELPER_DLL_IMPORT #define HELPER_DLL_EXPORT #define HELPER_DLL_LOCAL #endif #endif #ifdef DLL #ifdef DLL_EXPORTS #define API HELPER_DLL_EXPORT #else #define API HELPER_DLL_IMPORT #endif // DLL_EXPORTS #define LOCAL HELPER_DLL_LOCAL #else // DLL is not defined: build static lib. #define API #define LOCAL #endif // DLL #endif -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.218.30
文章代碼(AID): #1AMutajN (C_and_CPP)
文章代碼(AID): #1AMutajN (C_and_CPP)