mirror of
https://github.com/scummvm/scummvm-tools.git
synced 2026-05-21 05:40:44 +00:00
COMMON: Import STATIC_ASSERT
This commit is contained in:
committed by
Eugene Sandulenko
parent
7b1e313fed
commit
2b7dab2f74
@@ -479,5 +479,32 @@
|
||||
typedef uint16 OverlayColor;
|
||||
#endif
|
||||
|
||||
#ifndef STATIC_ASSERT
|
||||
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600)
|
||||
/**
|
||||
* 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) \
|
||||
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
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user