mirror of
https://github.com/w23/xash3d-fwgs
synced 2025-01-18 23:00:01 +01:00
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
This commit is contained in:
parent
5bae2f06ad
commit
a52d901f25
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h> // off_t
|
#include <sys/types.h> // off_t
|
||||||
#include STDINT_H
|
#include STDINT_H
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
typedef int sound_t;
|
typedef int sound_t;
|
||||||
@ -103,6 +104,11 @@ typedef uint64_t longtime_t;
|
|||||||
#define likely(x) (x)
|
#define likely(x) (x)
|
||||||
#endif
|
#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
|
#ifdef XASH_BIG_ENDIAN
|
||||||
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
|
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user