在Qt的qrect.h中,我发现类声明从这样开始:
class Q_CORE_EXPORT QRect {
};
Run Code Online (Sandbox Code Playgroud)
如您所见,类关键字后面有两个标识符.我怎么理解这个?
谢谢.
Mar*_*off 11
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
Run Code Online (Sandbox Code Playgroud)
这些值(__declspec(dllexport),__attribute__((visibility("default")))等)是特定于编译器的属性,表示动态库中函数的可见性.
| 归档时间: |
|
| 查看次数: |
2418 次 |
| 最近记录: |