GCC 递增宏
GCC Incremeting Macro
我定义了这样一个宏
#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|
会是什么原因?
正如你的错误所说,行:
NINC=NoisyInc(5);
在预处理过程中会变成:
(puts("incrementing"), (5)++)
5++
: 你不能 post-increment literals.
我定义了这样一个宏
#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|
会是什么原因?
正如你的错误所说,行:
NINC=NoisyInc(5);
在预处理过程中会变成:
(puts("incrementing"), (5)++)
5++
: 你不能 post-increment literals.