My codebase has an existing macro:
#define SOME_MACRO <macro definition>
For some changes I'm making, I want to add a new version of the macro that takes an argument.
#define SOME_MACRO(arg1) <macro definition>
I see that this question addresses selecting from multiple argument versions of a macro. However, the SOME_MACRO call does not already have parantheses. It's used as SOME_MACRO, not SOME_MACRO(). Is there any way to implement macro overloading such that SOME_MACRO calls SOME_MACRO(). I tried:
#define SOME_MACRO SOME_MACRO()
#define SOME_MACRO(...) <macro definition using __VA_ARGS__>
but that just got me a macro redefinition error. At the call site, this is what it currently looks like:
SOME_MACRO << "This is a test";
I want to add new calls of the form:
SOME_MACRO(foo) << "This is a test";
I want both calls to work, since the former is already in the code base. These are basically logging macros, and they create objects that expose a stream. On destruction, they write out the stream contents.