What problems might the following macro bring to the application?

前端 未结 6 2043
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 02:50

Can the following macro bring problems?

#define sq(x) x*x

If yes, then how and why?please help.

6条回答
  •  北恋
    北恋 (楼主)
    2021-01-27 03:24

    All of these can cause trouble:

    int x = 12;
    int n = sq(x+3);
    int y = sq(x++);
    int z = 2 * sq(2 + n) * n;
    

    comparared with a function sq.

提交回复
热议问题