diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/scummsys.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/common/scummsys.h b/common/scummsys.h index 4740127d2f..5486ba27c6 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -154,6 +154,7 @@ #endif #ifndef STATIC_ASSERT +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600) /** * Generates a compile-time assertion. * @@ -162,8 +163,21 @@ * time if the expression evaluates to false. */ #define STATIC_ASSERT(expression, message) \ - extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \ - (void)(STATIC_ASSERT_##message); + static_assert((expression), #message) +#else + /** + * Generates a compile-time assertion. + * + * @param expression An expression that can be evaluated at compile time. + * @param message An underscore-delimited message to be presented at compile + * time if the expression evaluates to false. + */ + #define STATIC_ASSERT(expression, message) \ + do { \ + extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \ + (void)(STATIC_ASSERT_##message); \ + } while (false) +#endif #endif // The following math constants are usually defined by the system math.h header, but |