xxx.h

#ifdef CFG_API_BEING_COMPILED

#ifdef WIN32

#define CFG_API_EXPORT __declspec(dllexport)

#else

#define CFG_API_EXPORT

#endif

#else

#if defined(WIN32) 

#define CFG_API_EXPORT __declspec(dllimport)

#else

#define CFG_API_EXPORT extern

#endif

#endif

 

CFG_API_EXPORT  int CFG_InitReq(

                               CFG_HANDLE* pHandle /*O: the */

  );

============================

在configuration Properties中

C/C++ --> Preprocessor --> Preprocessor Definitions

中加入WIN32; CFG_API_BEIGN_COMPILED;

 

对在VC工程中的.h文件来说,

 

在本工程中,#define CFG_API_EXPORT __declspec(dllexport) 有意义,

在函数头部加上CFG_API_EXPORT 宏的时候,是导出函数;

当别的工程来调用包含这个头文件的时候,并没有定义WIN32,CFG_API_BEIGN_COMPILED的宏,#define CFG_API_EXPORT __declspec(dllimport) 有意义

所以该头文件的函数又成为了导入函数。


相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-05-29
  • 2021-09-10
  • 2021-11-23
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2021-10-09
  • 2021-07-21
  • 2022-12-23
  • 2022-01-01
  • 2022-02-10
相关资源
相似解决方案