If you have a macro/function called SUM, isn't ADD implied? So why bother with it. It may be a better use of your time to come up with a more suitable SUM thing, if you're not satisfied with a simple function call.
Remember in C++, with variadic templates, it's possible to create a sum function that takes a variable number of arguments.
No, I don't think that works it should be 3 arguments in the 1st place.
I'm not suggesting a solution to the problem. I'm just trying to explain why your code doesn't work. I could be wrong, but it's how I understand it when reading the standard and it seems to be consistent with how the compiler behaves.
After all parameters in the replacement list have been substituted [...] Then the resulting preprocessing token sequence is rescanned [...] for more macro names to replace.
The way I interpret this is that sum will essentially get expanded first and not until after that has succeeded (which it doesn't in your code) it will go on and expand ADD in the resulting sequence.
I'm trying to do some C macro experiment where comma "," is replaced with a keyword like ADD
Why? The comma operator has clearly defined rules of usage in C and C++. ADD just obscures the intent IMO.
There are two versions of logical operators, symbols and text. && AND, || OR and ! NOT. The text operators are very clear with their usage and meaning. ADD is IMO at best ambiguous, with an implication of possibly adding together two values.
I certainly would never try to do something like this, I'd have a macro replace doing different duty that enhances readability. "Magic number" replacement, for example.
If you want to do some experimentation on macro replacement a suggestion is at least make the operator replacement closely match. , and COM or COMM or even COMMA.