I have a macro like this:
#define C( a... ) ( char *[] ){ a, 0 }
This works for non-empty arguments:
C( \"a\", \"b\" ) => (
Check out GCC's __VA_OPT__()
function macro that can be used within a variadic macro.
#define C(...) (char *[]) { __VA_ARGS__ __VA_OPT__(,) 0 }
C("a", "b"); expands to (char *[]) { "a", "b" , 0 };
C(); expands to (char *[]) { 0 };
The arguments passed to __VA_OPT__()
will only be expanded if __VA_ARGS__
is non-empty.