how does one define a macro expression in C, whose arguments are also expressions?
The problem I am tackling is how to write an expression MAX(X,Y)
that takes in the expressions X
and Y
(such as x++
or x+2
) and returns the maximum of the two. This expression should be defined in as a preprocessor macro.
Answer from a related post:
#define MAX(a, b) ((a) > (b) ? (a) : (b))
and I am aware of the risks involved with x++
in a macro (can be evaluated twice).
Kind regards