mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-03-10 12:01:43 +00:00
use _Static_assert for COMPILE_TIME_ASSERT if available
This commit is contained in:
parent
1baf872843
commit
633fa48842
1 changed files with 7 additions and 1 deletions
|
@ -89,8 +89,14 @@
|
||||||
/* Make sure the types really have the right
|
/* Make sure the types really have the right
|
||||||
* sizes: These macros are from SDL headers.
|
* sizes: These macros are from SDL headers.
|
||||||
*/
|
*/
|
||||||
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||||
|
#define COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
|
||||||
|
#elif defined(__cplusplus) && (__cplusplus >= 201103L)
|
||||||
|
#define COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
|
||||||
|
#else /* universal, but may trigger -Wunused-local-typedefs */
|
||||||
#define COMPILE_TIME_ASSERT(name, x) \
|
#define COMPILE_TIME_ASSERT(name, x) \
|
||||||
typedef int dummy_ ## name[(x) * 2 - 1]
|
typedef int dummy_ ## name[(x) * 2 - 1]
|
||||||
|
#endif
|
||||||
|
|
||||||
COMPILE_TIME_ASSERT(char, sizeof(char) == 1);
|
COMPILE_TIME_ASSERT(char, sizeof(char) == 1);
|
||||||
COMPILE_TIME_ASSERT(float, sizeof(float) == 4);
|
COMPILE_TIME_ASSERT(float, sizeof(float) == 4);
|
||||||
|
|
Loading…
Reference in a new issue