diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-08-31 15:39:30 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-09-16 12:27:59 +0000 |
commit | 8d6f2e7e157d5778e37e54cd7e90c3185970abff (patch) | |
tree | c11af6badcfbbd9525a361d38c827a4b0ac8a87e /src/corelib | |
parent | 31a63b69037c680101bf82a7161d4a0e5184dd86 (diff) |
Add a QT_REQUIRE_CONFIG(feature) macro
This macro expands into a static_assert and can be used to
trigger a compile error if a certain feature is not available
when trying to compile some code.
This is especially useful to protect against accidental inclusion
of headers that implement functionality related to a feature.
Change-Id: I456c55b989ce5f35f3af0e13c1886a85c23dfe29
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qglobal.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f11ec127e0..dd8b6110b3 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -78,6 +78,7 @@ 1: The feature is available */ #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 vailable.") #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define QT_NO_UNSHARABLE_CONTAINERS |