From bb7d180e40a303dad25511406a1b1fd81fa63d1a Mon Sep 17 00:00:00 2001 From: James Benton Date: Tue, 21 Feb 2017 20:06:18 +0000 Subject: [PATCH] Fix wut_structsize.h for compilers which do not have static_assert (pre C11) --- include/wut_structsize.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/wut_structsize.h b/include/wut_structsize.h index b711de6..ff1611f 100644 --- a/include/wut_structsize.h +++ b/include/wut_structsize.h @@ -3,13 +3,18 @@ #include // 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)