summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-02-03 15:44:08 -0800
committerMarc Mutz <marc.mutz@qt.io>2022-05-24 00:30:08 +0000
commiteb5a00ab5faaa08ced5578d777166d3aa4e08c6d (patch)
tree0bc35b9400f58f78c2590c29bbc97b7fc63c8e80
parent9c809205a40517e1a7975e72d1f607b4d3a131fe (diff)
qglobal: add a way to selectively export in Qt 6 XOR Qt 7
Because at least one compiler *cough*MSVC*cough* is unable to dllexport a method that is in a dllexport'ed class. Change-Id: I54f205f6b7314351b078fffd16d06b4e6ef0c086 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit ea89d0a36ca5b17998c62880f4802228314b1e2d) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--doc/global/qt-cpp-defines.qdocconf4
-rw-r--r--src/corelib/global/qglobal.h18
2 files changed, 21 insertions, 1 deletions
diff --git a/doc/global/qt-cpp-defines.qdocconf b/doc/global/qt-cpp-defines.qdocconf
index 0a49b37a02..5c762083a2 100644
--- a/doc/global/qt-cpp-defines.qdocconf
+++ b/doc/global/qt-cpp-defines.qdocconf
@@ -208,7 +208,9 @@ Cpp.ignoredirectives += \
QT_WARNING_DISABLE_INTEL \
QT_WARNING_DISABLE_MSVC \
Q_ATTRIBUTE_FORMAT_PRINTF \
- Q_MV_IOS
+ Q_MV_IOS \
+ QT6_ONLY \
+ QT7_ONLY
# Qt 6: Remove
falsehoods += \
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6e83b78f4b..43e4c3fe57 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -107,6 +107,24 @@
#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
#define QT_REQUIRE_CONFIG(feature) Q_STATIC_ASSERT_X(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.")
+/*
+ helper macros to make some simple code work active in Qt 6 or Qt 7 only,
+ like:
+ struct QT6_ONLY(Q_CORE_EXPORT) QTrivialClass
+ {
+ void QT7_ONLY(Q_CORE_EXPORT) void operate();
+ }
+*/
+#if QT_VERSION_MAJOR == 7
+# define QT7_ONLY(...) __VA_ARGS__
+# define QT6_ONLY(...)
+#elif QT_VERSION_MAJOR == 6
+# define QT7_ONLY(...)
+# define QT6_ONLY(...) __VA_ARGS__
+#else
+# error Qt major version not 6 or 7
+#endif
+
/* These two macros makes it possible to turn the builtin line expander into a
* string literal. */
#define QT_STRINGIFY2(x) #x