common: fix broken STATIC_ASSERT macro again

This commit is contained in:
Alibek Omarov 2024-01-12 23:00:56 +03:00
parent aaa9fbd50f
commit 2ae038c01c

View File

@ -121,15 +121,18 @@ typedef uint64_t longtime_t;
#define likely(x) (x) #define likely(x) (x)
#endif #endif
#if __STDC_VERSION >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword #if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
#define STATIC_ASSERT_ static_assert #define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
#define STATIC_ASSERT static_assert #define STATIC_ASSERT static_assert
#elif __STDC_VERSION >= 201112L // in C11 it's _Static_assert #elif __STDC_VERSION__ >= 201112L // in C11 it's _Static_assert
#define STATIC_ASSERT_ _Static_assert #define STATIC_ASSERT_( ignore, x, y ) _Static_assert( x, y )
#define STATIC_ASSERT _Static_assert #define STATIC_ASSERT _Static_assert
#else #else
#define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1] #define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_( static_assert_##__LINE__, x, y ) // need these to correctly expand the line macro
#define STATIC_ASSERT_3( line, x, y ) STATIC_ASSERT_( static_assert_ ## line, x, y )
#define STATIC_ASSERT_2( line, x, y ) STATIC_ASSERT_3( line, x, y )
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
#endif #endif
#ifdef XASH_BIG_ENDIAN #ifdef XASH_BIG_ENDIAN