我定义了这样一个宏
#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|原因是什么?
发布于 2015-03-17 10:47:07
正如您的错误所述,行:
NINC=NoisyInc(5);
在预处理期间,将变成:
(puts("incrementing"), (5)++)
5++:您不能使用增量后的文字.
https://stackoverflow.com/questions/29097026
复制相似问题