我已经创建了一个DLL文件,在头文件中我看到:
#ifdef WIN32DLL_EXPORTS
Run Code Online (Sandbox Code Playgroud)
我不明白它是什么意思,我们在哪里/如何设置WIN32DLL_EXPORTS.
如果我使用:
#ifdef WIN32DLL_EXPORTS
#define WIN32DLL_API __declspec(dllexport)
#else
#define WIN32DLL_API __declspec(dllimport)
#endif
WIN32DLL_API int testSum(void);
Run Code Online (Sandbox Code Playgroud)
testSum被认为是__declspec(dllimport).所以我认为我的项目没有设定WIN32DLL_EXPORTS?我怎么能改变这个?
Ray*_*hen 11
在您引用的行的正上方有一个注释块.阅读.
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the WIN32DLL_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// WIN32DLL_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef WIN32DLL_EXPORTS
#define WIN32DLL_API __declspec(dllexport)
#else
#define WIN32DLL_API __declspec(dllimport)
#endif
Run Code Online (Sandbox Code Playgroud)