Macros and postincrement

后端 未结 8 1952
庸人自扰
庸人自扰 2020-12-02 02:13

Here\'s some more weird macro behavior I was hoping somebody could shed light on:

#define MAX(a,b) (a>b?a:b)

void main(void)
{
  int a = 3, b=4;

  print         


        
8条回答
  •  孤街浪徒
    2020-12-02 02:49

    Macros are evaluated by the preprocessor which stupidly replaces all according to the macro definitions. In your case, MAX(a++, b++) becomes (a++>b++) ? a++ : b++.

提交回复
热议问题