How to make a variadic macro (variable number of arguments)

c, c-preprocessor, g++, variadic

Solution

C99 way:

#define FOO(...) printf(__VA_ARGS__)

Problem

I want to write a macro in C that accepts any number of parameters, not a specific number example: ``` #define macro( X ) something_complicated( whatever( X ) ) ``` where `X` is any number of parameters I need this because `whatever` is overloaded and can be called with 2 or 4 parameters. I tried defining the macro twice, but the second definition overwrote the first one! The compiler I'm working with is g++ (more specifically, mingw)

Original source