GCC增加宏

时间:2015-03-17 10:42:37

标签: gcc macros

我定义了一个像这样的宏

#define NoisyInc(x) (puts("incrementing"), (x)++)
int NINC;
NINC=NoisyInc(5);
printf("NoisyInc is %d\n",NINC);

但在构建程序时遇到此错误

C:\Users\DTS\Desktop\macros.c|36|error: lvalue required as increment operand|

原因是什么?

1 个答案:

答案 0 :(得分:0)

正如您的错误所说,行:

NINC=NoisyInc(5);

在预处理期间将变为:

(puts("incrementing"), (5)++)

5++:你不能后增加文字。