mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-07 23:40:44 +01:00
Fix wut_structsize.h for compilers which do not have static_assert (pre C11)
This commit is contained in:
parent
1a1a87a948
commit
bb7d180e40
@ -3,13 +3,18 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
// Ensure structs are correct size & offsets
|
// Ensure structs are correct size & offsets
|
||||||
#define CHECK_SIZE(Type, Size) \
|
#if defined(static_assert)
|
||||||
static_assert(sizeof(Type) == Size, \
|
# define CHECK_SIZE(Type, Size) \
|
||||||
#Type " must be " #Size " bytes")
|
static_assert(sizeof(Type) == Size, \
|
||||||
|
#Type " must be " #Size " bytes")
|
||||||
|
|
||||||
#define CHECK_OFFSET(Type, Offset, Field) \
|
# define CHECK_OFFSET(Type, Offset, Field) \
|
||||||
static_assert(offsetof(Type, Field) == Offset, \
|
static_assert(offsetof(Type, Field) == Offset, \
|
||||||
#Type "::" #Field " must be at offset " #Offset)
|
#Type "::" #Field " must be at offset " #Offset)
|
||||||
|
#else
|
||||||
|
# define CHECK_SIZE(Type, Size)
|
||||||
|
# define CHECK_OFFSET(Type, Offset, Field)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Workaround weird macro concat ## behaviour
|
// Workaround weird macro concat ## behaviour
|
||||||
#define PP_CAT(a, b) PP_CAT_I(a, b)
|
#define PP_CAT(a, b) PP_CAT_I(a, b)
|
||||||
|
Loading…
Reference in New Issue
Block a user