Overloading a macro
问题 I'm trying to overload a macro by the number of parameter. Of course I can't actually overload the macro. I've tried using variadic macros to choose the right macro (using the fact that if __VA_ARGS__ doesn't exist it's supposed to delete the last coma before it - GCC Reference ): #define TEST1() printf("TEST1"); #define TEST2() printf("TEST2"); #define CHOOSER(x, y,FUNC,...) FUNC() #define MANIMACRO(...) CHOOSER(,__VA_ARGS__,TEST1,TEST2) int main(void) { MANIMACRO(1); MANIMACRO(); } The idea