Debug.h: Implement a real STATIC_ASSERT on non-GCC2.
This commit is contained in:
@@ -69,12 +69,18 @@
|
||||
# define ASSERT_PRINT(x, format, args...) do { } while(0)
|
||||
#endif
|
||||
|
||||
#define STATIC_ASSERT(x) \
|
||||
do { \
|
||||
struct __staticAssertStruct__ { \
|
||||
char __static_assert_failed__[2*(x) - 1]; \
|
||||
}; \
|
||||
} while (false)
|
||||
#if __GNUC__ >= 5 && !defined(__cplusplus)
|
||||
# define STATIC_ASSERT(x) _Static_assert(x, "static assert failed!")
|
||||
#elif defined(__cplusplus) && __cplusplus >= 201103L
|
||||
# define STATIC_ASSERT(x) static_assert(x, "static assert failed!")
|
||||
#else
|
||||
# define STATIC_ASSERT(x) \
|
||||
do { \
|
||||
struct __staticAssertStruct__ { \
|
||||
char __static_assert_failed__[2*(x) - 1]; \
|
||||
}; \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#if KDEBUG
|
||||
# define KDEBUG_ONLY(x) x
|
||||
|
||||
Reference in New Issue
Block a user