奇怪的类声明 [英] Strange class declaration
本文介绍了奇怪的类声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Qt的qrect.h中我发现类声明开始如下:
In Qt's qrect.h I found class declaration starting like this:
class Q_CORE_EXPORT QRect {
};
正如你可以看到class关键字后有两个标识符。我如何理解这个?
谢谢。
As you can see there are two identifiers after class keyword. How shall I understand this?
Thank you.
推荐答案
Q_CORE_EXPORT
是一个可扩展为不同值的宏,具体取决于
来自该来源的片段:
#ifndef Q_DECL_EXPORT
# ifdef Q_OS_WIN
# define Q_DECL_EXPORT __declspec(dllexport)
# elif defined(QT_VISIBILITY_AVAILABLE)
# define Q_DECL_EXPORT __attribute__((visibility("default")))
# endif
# ifndef Q_DECL_EXPORT
# define Q_DECL_EXPORT
# endif
#endif
#ifndef Q_DECL_IMPORT
# ifdef Q_OS_WIN
# define Q_DECL_IMPORT __declspec(dllimport)
# else
# define Q_DECL_IMPORT
# endif
#endif
// ...
# if defined(QT_BUILD_CORE_LIB)
# define Q_CORE_EXPORT Q_DECL_EXPORT
# else
# define Q_CORE_EXPORT Q_DECL_IMPORT
# endif
这些值( __ declspec(dllexport)
, __ attribute __默认)))
等)是指示动态库中函数可见性的编译器特定属性。
Those values (__declspec(dllexport)
, __attribute__((visibility("default")))
, etc.) are compiler-specific attributes indicating visibility of functions in dynamic libraries.
这篇关于奇怪的类声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文