2013-02-22 11:00:32 +00:00
|
|
|
|
2020-11-08 00:29:35 +00:00
|
|
|
#ifdef __clang__
|
2020-04-08 11:37:31 +00:00
|
|
|
|
2020-11-08 00:29:35 +00:00
|
|
|
// clang already includes the condition in the error message and emits
|
|
|
|
// an additional warning here if we use the variant without message
|
|
|
|
#define compiletimeassert(cond) _Static_assert(cond,"")
|
|
|
|
|
|
|
|
#elif __STDC_VERSION__ >= 201710L
|
|
|
|
|
|
|
|
#define compiletimeassert(cond) _Static_assert(cond,#cond)
|
2020-04-08 11:37:31 +00:00
|
|
|
|
2020-04-17 07:50:37 +00:00
|
|
|
#elif __STDC_VERSION__ >= 201112L
|
|
|
|
|
2020-11-08 00:29:35 +00:00
|
|
|
#define compiletimeassert(cond) _Static_assert(cond,#cond)
|
2020-04-17 07:50:37 +00:00
|
|
|
|
2020-04-08 11:37:31 +00:00
|
|
|
#else
|
|
|
|
|
2013-02-22 11:00:32 +00:00
|
|
|
#define __X(x, y) x ## y
|
|
|
|
#define __Y(x, y) __X(x, y)
|
|
|
|
#define compiletimeassert(cond) struct __Y(foo,__LINE__) { char __temp[1 - (!(cond))*2]; };
|
2020-04-08 11:37:31 +00:00
|
|
|
|
|
|
|
#endif
|