小编ral*_*lph的帖子

C预处理器更换无法正常工作

#include <stdio.h>
#define VAR cc

int main(void) {
    int ccc = 9;
    printf("hell loo %d", VARc);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我对这段代码的理解意味着预处理器找到的任何地方VAR都会替换它cc,因此printf会有一个正确定义的变量ccc,但代码会出错.有人可以请帮助


编辑1

我得到的错误是

test.c: In function ‘main’:
test.c:16: error: ‘VARc’ undeclared (first use in this function)
test.c:16: error: (Each undeclared identifier is reported only once
test.c:16: error: for each function it appears in.)
Run Code Online (Sandbox Code Playgroud)

c preprocessor c-preprocessor

2
推荐指数
1
解决办法
155
查看次数

标签 统计

c ×1

c-preprocessor ×1

preprocessor ×1