In short, the gcc and vC ++ preprocessors have different outputs with the same input. Variable macros in vC ++ do not seem to perform "argument matching" (if that is the correct term) if passed to other macros. For example:
#define MACRO(a, ...) head:a, tail:MACRO_OTHER(__VA_ARGS__) #define MACRO_OTHER(a, ...) head:a, tail:__VA_ARGS__
FROM
MACRO(1, 2, 3, 4, 5)
Gcc output:
head:1, tail:head:2, tail:3,4,5
vC ++ output:
head:1, tail:head:2,3,4,5, tail:
Apparently a in MACRO_OTHER has 2,3,4,5 with an empty section of variational arguments. With that in mind, is there a way to create an alternative to vC ++ for the next macro (which works fine with gcc)
#define VA_TYPES_WITH_ARGS(...) __VA_TYPES_WITH_ARGS(VA_NUM_ARGS(__VA_ARGS__),##__VA_ARGS__) #define __VA_TYPES_WITH_ARGS(n, ...) _VA_TYPES_WITH_ARGS(n,##__VA_ARGS__) #define _VA_TYPES_WITH_ARGS(n, ...) _VA_TYPES_WITH_ARGS_##n(__VA_ARGS__) #define _VA_TYPES_WITH_ARGS_0() #define _VA_TYPES_WITH_ARGS_1(type ) type _arg1 #define _VA_TYPES_WITH_ARGS_2(type, ...) type _arg2, _VA_TYPES_WITH_ARGS_1(__VA_ARGS__) #define _VA_TYPES_WITH_ARGS_3(type, ...) type _arg3, _VA_TYPES_WITH_ARGS_2(__VA_ARGS__)
It basically adds _argK for each argument.
Example:
VA_TYPES_WITH_ARGS(int, bool, float)
will expand to
int _arg3, bool _arg2, float _arg1
Any help would be greatly appreciated.
Preprocessor related questions:
The difference between gcc and Microsoft preprocessor
Unexpected behavior of the GCC and VC ++ preprocessor