Consider the following C program (ignore the double side effect problem):
#define max(a, b) (a>b?a:b)
int main(void){
int max = max(5,6);
return max;
}
The GCC preprocessor turns this into:
int main(void){
int max = (5>6?5:6);
return max;
}
This is pretty nice since you donβt have to worry about inadvertent collisions between maxand max(). The GCC manual says:
A functional macro expands only if its name appears with a pair of parentheses after it. If you write only a name, it stays alone
Is it standardized or is it just something done by convention?
mensi source
share