summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-11 11:35:19 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-19 19:38:23 +0200
commit3e1d03b1eaf6a5e842bed4ae4f9bb8cca05e5b31 (patch)
tree74dd3478dce3bc96121238300fc0bbc6ef97fc3e /src/corelib/global/qglobal.cpp
parent5b686e208ffc68f9f660d36c468280d50a40e3ad (diff)
Port Q_STATIC_ASSERT(_X) to static_assert
There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r--src/corelib/global/qglobal.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4d990f5bb5..460a36e2bc 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -133,15 +133,15 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
// in. The idea here is to error or warn if otherwise implicit Qt
// assumptions are not fulfilled on new hardware or compilers
// (if this list becomes too long, consider factoring into a separate file)
-Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
-Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits");
-Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly");
-Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits");
-Q_STATIC_ASSERT_X(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
-Q_STATIC_ASSERT_X(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
-Q_STATIC_ASSERT_X(std::numeric_limits<int>::radix == 2,
+static_assert(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
+static_assert(sizeof(int) == 4, "Qt assumes that int is 32 bits");
+static_assert(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly");
+static_assert(sizeof(float) == 4, "Qt assumes that float is 32 bits");
+static_assert(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits");
+static_assert(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits");
+static_assert(std::numeric_limits<int>::radix == 2,
"Qt assumes binary integers");
-Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
+static_assert((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1,
"Qt assumes two's complement integers");
// While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011
@@ -152,13 +152,13 @@ Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::l
// On GHC the compiler reports std::numeric_limits<float>::is_iec559 as false.
// This is all right according to our needs.
#if !defined(Q_CC_GHS)
-Q_STATIC_ASSERT_X(std::numeric_limits<float>::is_iec559,
+static_assert(std::numeric_limits<float>::is_iec559,
"Qt assumes IEEE 754 floating point");
#endif
// Technically, presence of NaN and infinities are implied from the above check,
// but double checking our environment doesn't hurt...
-Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity &&
+static_assert(std::numeric_limits<float>::has_infinity &&
std::numeric_limits<float>::has_quiet_NaN &&
std::numeric_limits<float>::has_signaling_NaN,
"Qt assumes IEEE 754 floating point");
@@ -167,13 +167,13 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity &&
// but that allows for a non-binary radix. We need to recheck that.
// Note how __STDC_IEC_559__ would instead check for IEC 60559:1989, aka
// ANSI/IEEE 754−1985, which specifically implies binary floating point numbers.
-Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2,
+static_assert(std::numeric_limits<float>::radix == 2,
"Qt assumes binary IEEE 754 floating point");
// not required by the definition of size_t, but we depend on this
-Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
-Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
-Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
+static_assert(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size");
+static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition
+static_assert((std::is_same<qsizetype, qptrdiff>::value));
/*!
\class QFlag