I'm trying to do something using C preprocessor. I have this macros:
#define _MAX(x, y) (((x)) > ((y))) ? (x) : (y))
#define MAX1 _MAX(1,
#define MAX2 _MAX(2,0))
#define RIGHT _MAX(1,_MAX(2,0))
#define WRONG MAX1 MAX2
In this case, RIGHT gives me the right expression but WRONG, even though it's the same, expands the macro to blank.
It seems to me that's because after expanding MAX1 to _MAX(1, it detects there is a _MAX macro to expand and tries to do it without expanding the MAX2, which haves the other half of the statement.
If I'm right, is there any way that I can delay the _MAX macro expansion until MAX2 it's expanded?
error: unterminated argument list invoking macro "_MAX"- Karoly Horvath