Unbeabsichtigte mehrfache Auswertung von Parametern im Makro
Warum beträgt die Ausgabe des zweiten Ausdrucks: max. 50 und 67 62? Warum nicht max von 50 und 62 ist 57?
#define MAX(a,b) ((a)>(b) ? (a): (b))
int incr(){
static int i =42;
i += 5;
return i;
}
int _tmain(int argc, _TCHAR* argv[])
{
int x = 50;
printf("max of %d and %d is %d\n",x, incr(), MAX(x, incr()));
printf("max of %d and %d is %d",x, incr(), MAX(x, incr()));
return 0;
}