Assume static_assert is available everywhere in C++

I'm not adding a static_assert(Q_COMPILER_STATIC_ASSERT),
as ironic as that might be; we have enough
static_asserts around already which will surely cause
errors, in case of a broken compiler.

The detection itself has to stay around for C support.

Change-Id: Id32f5c8e0ab2e461fba7b0525da5eeaaea77c68d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Giuseppe D'Angelo 2020-06-11 14:47:53 +02:00
parent 1053e1f4a3
commit a769ca1d91

View File

@ -111,7 +111,9 @@
*/ */
#define Q_UNUSED(x) (void)x; #define Q_UNUSED(x) (void)x;
#if defined(__cplusplus) && defined(Q_COMPILER_STATIC_ASSERT) #if defined(__cplusplus)
// Don't use these in C++ mode, use static_assert directly.
// These are here only to keep old code compiling.
# define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition) # define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
# define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message) # define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
#elif defined(Q_COMPILER_STATIC_ASSERT) #elif defined(Q_COMPILER_STATIC_ASSERT)