I have the following macro:
#define HEX 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
#define BITS 0x01
#define ADD_FLAGS(a, b, c, d, e, f, g, h) \
a, b | BITS, c, d, e, f, g, h
I use this somewhere to create a byte array {ADD_FLAGS(HEX)}. This doesn't work. HEX is interpreted as a single argument to ADD_FLAGS and I get errors that there are too few arguments.
const myStructure Table[ENTRY_COUNT] =
{
/* Entity Index 0 */
{
<some structure fields>,
ADD_FLAGS(HEX), // 8-byte array
<more structure fields>
}
}
I have also tried the following variants, but no success:
#define EXPAND(x) x
#define ADD_FL(a, b, c, d, e, f, g, h) \
a, b | BITS, c, d, e, f, g, h
#define ADD_FLAGS(...) ADD_FL EXPAND((__VA_ARGS__))
##################### other variant
#define ADD_FLAGS(...) EXPAND(ADD_FL (__VA_ARGS__))
I am using C99 and three different compilers, so any answer has to be standards compliant, otherwise there is surely going to be a comiler that's not working (I am using armclang, ghs and tasking).