I'm familiar with the following way of creating a macro with variable number of arguments. However, consider:
#define MY_MACRO_N(value, format, ...) my_func(value, format, ##__VA_ARGS__)
#define MY_MACRO_0(value) my_func(value, NULL)
Where my_func
takes variable number of arguments as well. How can I create a MY_MACRO
macro that encapsulates both, such that:
MY_MACRO(my_value); // expand to my_func(my_value, NULL);
MY_MACRO(my_value, my_format); // expand to my_func(my_value, my_format);
MY_MACRO(my_value, my_format, a, b); // expand to my_func(my_value, my_format, a, b);
MY_MACRO(); // invalid
The variable number of arguments break the GET_MACRO
approach, however it seems like there should be a way to do this.