Here's the answer to if someone wants to do the same.
#define _PP_0(_1, ...) _1
where PP_NARG is the macro that counts the number of arguments, and PP_JOIN is the macro connecting the tokens (i.e. PP_JOIN(a,b) => ab ). You will also need to schedule PP_NARG if you want to process more than 64 arguments.
Now back to the original question. Solution using PP_TRANSFORM :
#define FUNCTION(name, dummy) void name(); #define FUNCTION_TABLE(...) PP_TRANSFORM(FUNCTION,dummy,__VA_ARGS__)
if you want to generate C ++ implementation functions, you can use this opaque parameter x PP_TRANSFORM :
#define FUNCTION_CPP(name, class) void class::name(){} #define FUNCTION_TABLE_CPP(...) PP_TRANSFORM(FUNCTION_CPP,MyClass,__VA_ARGS__)
All of this works equally well with the GCC and MSVC preprocessors; PP_TRANSFORM_NN does not use __VA_ARGS__ to avoid separate implementations of 100 definitions for GCC and MSVC
Pavel
source share