DLL導出函數和類的定義區別 __declspec(dllexport)


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文件的

別搞錯了,搞錯了就會出問題啦~~~~

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM