这个c ++类声明是什么意思? [英] What does this c++ class declaration mean?
问题描述
我在阅读的文章中看到了这段代码。
I saw this piece of code in an article I am reading.
class EXAMPLEUNMANAGEDDLL_API CUnmanagedTestClass
{
public:
CUnmanagedTestClass();
virtual ~CUnmanagedTestClass();
};
EXAMPLEUNMANAGEDDLL_API有什么作用?
What does EXAMPLEUNMANAGEDDLL_API do?
谢谢预先
推荐答案
这是为了将类的功能导出或导入DLL。
This is for the purpose of exporting or importing the functions of a class into a DLL.
在MSDN上阅读此文章以获取更多信息:在C ++类中使用dllimport和dllexport
Read this article on MSDN for additional information: Using dllimport and dllexport in C++ Classes
常见的做法是在类的标头中使用条件编译,以便相同标头可用于生成DLL或使用DLL:
The common practice is to use conditional compilation in the headers of the class, so that the same header can be used for producing the DLL or consuming the DLL:
#ifdef EXAMPLEUNMANAGEDDLL_EXPORTS
#define EXAMPLEUNMANAGEDDLL_API __declspec(dllexport)
#else
#define EXAMPLEUNMANAGEDDLL_API __declspec(dllimport)
#endif
在此示例中,您库的代码或构建脚本将定义符号 EXAMPLEUNMANAGEDDLL_EXPORTS
。
In this example, the code or the buildscripts of your library would define symbol EXAMPLEUNMANAGEDDLL_EXPORTS
.
这篇关于这个c ++类声明是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!