这种C ++类声明是什么意思? [英] What does this kind of C++ class declaration mean?
问题描述
我下载了Ogre3D源代码,并发现了这种类声明:
I downloaded Ogre3D source code, and found this kind of class declaration:
class _OgreExport TimeIndex
{ ...
我知道 TimeIndex是类名,但是 _OgreExport在中间? CPP参考不包括此类的类声明表单。这是什么?
I know "TimeIndex" is the class name, but what is the "_OgreExport" in the middle? CPP reference doesn't include this kind of class declaration form. What is this?
推荐答案
_OgreExport
是预处理器指令,可扩展为要么
_OgreExport
is a preprocessor directive that expands to either
__declspec(dllimport)
文件包含在其模块之外或
when the file is included outside its module or
__declspec(dllexport)
否则。在Windows下,您必须指定要导出/导入的类/方法,以便可以在二进制文件中使用它们。
otherwise. Under Windows, you have to specify which classes/methods you want exported/imported so that they can be used across binaries.
从技术上讲,正如James在评论中指出的那样,宏名称是非法的,因为它以下划线开头。这些名称是为实现保留的。
Technically, as James pointed out in the comments, the macro name is illegal, since it begins with an underscore. These names are reserved for the implementation.
这篇关于这种C ++类声明是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!