lzpong

DLL导出函数和类的定义区别 __declspec(dllexport)

是有区别的, 请看 :

//定义头文件的使用方,是导出还是导入
#if defined(_DLL_API)
#ifndef DLL_API
#define DLL_API __declspec(dllexport)
#endif
#else
#define DLL_API __declspec(dllimport)
#endif // !DLL_API
#ifndef _API
#ifdef _MSC_VER
#define _API __stdcall
#else
#define _API
#endif
#endif

//导出函数,若要导出函数,必须出现在调用约定关键字的左边(最左边)
DLL_API int add(int a,int b);

//导出类,要导出类中的所有公共数据成员和成员函数,必须出现在类名的左边(挨着)
class DLL_API cls
{
public:
   int add(int a,int b);
}

  这样会自动产生 .lib文件和 .dll文件的

别搞错了,搞错了就会出问题啦~~~~

 

分类:

技术点:

相关文章:

  • 2022-01-09
  • 2021-09-14
  • 2022-01-03
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2022-12-23
  • 2022-02-04
  • 2021-09-13
  • 2022-12-23
  • 2021-12-23
  • 2021-08-31
相关资源
相似解决方案