1 // Definitions of helper macros for tests of flexible array members.
2 
3 #if __cplusplus < 201102L
4 #  define _CAT(x, y)  x ## y
5 #  define CAT(x, y)  _CAT (x, y)
6 
7 // Generate a struct with a unique name containing a bitfield
8 // of size that must evaluate to a non-zero value, otherwise
9 // generate a compiler error.
10 #  define ASSERT(expr)                                                  \
11   struct CAT (FAM_Assert, __LINE__) { unsigned asrt: 0 != (expr); }
12 #else
13 // In C++ 11 and beyond, use static_assert.
14 # define ASSERT(expr) static_assert (expr, #expr)
15 #endif
16 
17 // Macro to verify that a flexible array member is allocated
18 // at the very end of the containing struct.
19 #define ASSERT_AT_END(T, m)                             \
20   ASSERT (__builtin_offsetof (T, m) == sizeof (T))
21 
22 typedef __SIZE_TYPE__ size_t;
23