A macro (see below) to return the greater of two numbers is added by 1. But, the effect of the addition is absent.
PS: I have also checked by adding excessive brackets to the macro.
#define max(a,b) (a >= b ? a : b);
void main(){
int result = max(5,10) + 1; //result = 10
}
Solutions: CASE 1:
By manually replacing the macro in the expression (just as the pre-processor does, I think), the addition is performed correctly.
result = (5 >= 10 ? 5 : 10) + 1; // Evaluates correctly to 11.
CASE 2: The expression also evaluates correctly when the order of the operands are reversed.
result = 1 + max(5,10); //Evaluates correctly to 11.
Why is the original expression not working as intended while the two solution cases do?