diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-02-13 14:42:50 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-04-16 22:17:51 +0200 |
commit | 044a29bc66fbc8621f6cbe1bc2f8bd36dcd23d74 (patch) | |
tree | 521f20cf65f92cdf067f40b2ecdb523160defa3a | |
parent | 3b81d04bc6073d66ef3ac4a00e3c18e84057e106 (diff) |
corelib/global/*.h: use static_assert instead of Q_STATIC_ASSERT_X
qtconfigmacros:
Otherwise we'd need to include <QtCore/qassert.h> before using
QT_REQUIRE_CONFIG. It cannot be added here as qassert.h itself uses
QT_CONFIG, i.e. qassert.h needs to include this header. And
Q_STATIC_ASSERT_X is only kept around to keep old code working.
_Static_assert is deprecated in C23:
https://en.cppreference.com/w/c/language/_Static_assert
Change-Id: Ie60a02274cc5be8bd1c6dc3819ccfbc2e7864a21
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qtconfigmacros.h | 4 | ||||
-rw-r--r-- | src/corelib/global/qtypes.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/global/qtconfigmacros.h b/src/corelib/global/qtconfigmacros.h index 2bb1016cac..a89894ff24 100644 --- a/src/corelib/global/qtconfigmacros.h +++ b/src/corelib/global/qtconfigmacros.h @@ -10,6 +10,8 @@ #include <QtCore/qtconfiginclude.h> +#include <assert.h> + /* The Qt modules' export macros. The options are: @@ -58,7 +60,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 available.") +#define QT_REQUIRE_CONFIG(feature) static_assert(QT_FEATURE_##feature == 1, "Required feature " #feature " for file " __FILE__ " not available.") /* moc compats (signals/slots) */ #ifndef QT_MOC_COMPAT diff --git a/src/corelib/global/qtypes.h b/src/corelib/global/qtypes.h index fa41f03c44..d08a919c13 100644 --- a/src/corelib/global/qtypes.h +++ b/src/corelib/global/qtypes.h @@ -11,6 +11,8 @@ #ifdef __cplusplus # include <cstddef> # include <cstdint> +#else +# include <assert.h> #endif #if 0 @@ -58,7 +60,7 @@ typedef quint64 qulonglong; #ifndef __cplusplus // In C++ mode, we define below using QIntegerForSize template -Q_STATIC_ASSERT_X(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions"); +static_assert(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions"); typedef ptrdiff_t qptrdiff; typedef ptrdiff_t qsizetype; typedef ptrdiff_t qintptr; |