29 lines
618 B
C
29 lines
618 B
C
#ifndef _MACROS_H_
|
|
#define _MACROS_H_
|
|
|
|
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
|
|
|
#define GLUE(a, b) a ## b
|
|
#define GLUE2(a, b) GLUE(a, b)
|
|
|
|
// Avoid compiler warnings for unused variables
|
|
#ifdef __GNUC__
|
|
#define UNUSED __attribute__((unused))
|
|
#else
|
|
#define UNUSED
|
|
#endif
|
|
|
|
// Ignore GLOBAL_ASM blocks when syntax-checking with GCC
|
|
#ifdef __GNUC__
|
|
#define GLOBAL_ASM(...)
|
|
#endif
|
|
|
|
// Static assertions
|
|
#ifdef __GNUC__
|
|
#define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
|
|
#else
|
|
#define STATIC_ASSERT(cond, msg) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
|
|
#endif
|
|
|
|
#endif
|