Browse Source

common: add STATIC_ASSERT macro

We're trying to guess if we have C11 static_assert defined in assert.h
otherwise use good ol' trick with negative array
pull/2/head
Alibek Omarov 2 years ago
parent
commit
a52d901f25
  1. 6
      common/xash3d_types.h

6
common/xash3d_types.h

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include <sys/types.h> // off_t
#include STDINT_H
#include <assert.h>
typedef unsigned char byte;
typedef int sound_t;
@ -103,6 +104,11 @@ typedef uint64_t longtime_t; @@ -103,6 +104,11 @@ typedef uint64_t longtime_t;
#define likely(x) (x)
#endif
#if defined( static_assert ) // C11 static_assert
#define STATIC_ASSERT static_assert
#else
#define STATIC_ASSERT( x, y ) extern int _static_assert_##__LINE__[( x ) ? 1 : -1]
#endif
#ifdef XASH_BIG_ENDIAN
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))

Loading…
Cancel
Save