mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-06 14:18:15 +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>
|
||||
|
||||
// Ensure structs are correct size & offsets
|
||||
#define CHECK_SIZE(Type, Size) \
|
||||
static_assert(sizeof(Type) == Size, \
|
||||
#Type " must be " #Size " bytes")
|
||||
#if defined(static_assert)
|
||||
# define CHECK_SIZE(Type, Size) \
|
||||
static_assert(sizeof(Type) == Size, \
|
||||
#Type " must be " #Size " bytes")
|
||||
|
||||
#define CHECK_OFFSET(Type, Offset, Field) \
|
||||
static_assert(offsetof(Type, Field) == Offset, \
|
||||
#Type "::" #Field " must be at offset " #Offset)
|
||||
# define CHECK_OFFSET(Type, Offset, Field) \
|
||||
static_assert(offsetof(Type, Field) == 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
|
||||
#define PP_CAT(a, b) PP_CAT_I(a, b)
|
||||
|
Loading…
Reference in New Issue
Block a user