作者adxis (acer)
看板C_and_CPP
标题Re: [问题] Singleton 与 DLL
时间Tue Jul 14 03:41:23 2009
※ 引述《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