Strange class declaration

In Qt qrect.h, I found a class declaration starting as follows:

class Q_CORE_EXPORT QRect { }; 

As you can see, there are two identifiers after the class keyword. How can I understand that? Thanks.

+5
c ++ class
source share
2 answers

Q_CORE_EXPORT macro that expands to different values depending on the context in which it is compiled.

Excerpt from this source:

 #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 

These values ​​( __declspec(dllexport) , __attribute__((visibility("default"))) , etc.) are compiler-specific attributes that indicate the visibility of functions in dynamic libraries.

+9
source share

Q_CORE_EXPORT is not an identifier. This is a platform-specific macro and is used to indicate a class that is intended to be used across library boundaries. In particular, it is defined by the Qt core base and is used by other Qt libraries.

+5
source share

All Articles