返回信息流#define A 1
enum T{A,B,C};
int A=5;
这样定义不同类型的A会有问题吗,求高手解答
这是一条镜像帖。来源:北邮人论坛 / cpp / #80378同步于 2014/6/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
C语言中这样的定义有问题吗
lishenan2008
2014/6/21镜像同步10 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
有问题的。
源码预处理后,所有A会被替换成1
【 在 lishenan2008 的大作中提到: 】
: #define A 1
: enum T{A,B,C};
: int A=5;
: ...................
可以gcc -E 看一下展开的结果
xxx@xxx:~/code/test$ cat gcce.c
#define A 1
enum T{A,B,C};
int A=5;
int main() {
return 0;
}
xxx@xxx:~/code/test$ gcc gcce.c -E
# 1 "gcce.c"
# 1 "<command-line>"
# 1 "gcce.c"
enum T{1,B,C};
int 1=5;
int main() {
return 0;
}
新技能get√
【 在 buptxrc ([若晨团]|若晨|徐小夫) 的大作中提到: 】
: 可以gcc -E 看一下展开的结果
: xxx@xxx:~/code/test$ cat gcce.c
: #define A 1
: ...................
哇,新技能~
【 在 buptxrc ([若晨团]|若晨|徐小夫) 的大作中提到: 】
: 可以gcc -E 看一下展开的结果
: xxx@xxx:~/code/test$ cat gcce.c
: #define A 1
: ...................
通过『我邮2.0』发布
【 在 buptxrc 的大作中提到: 】
: 可以gcc -E 看一下展开的结果
: xxx@xxx:~/code/test$ cat gcce.c
: #define A 1
: ...................
学习了,thank you
赞!
【 在 buptxrc 的大作中提到: 】
: 可以gcc -E 看一下展开的结果
: xxx@xxx:~/code/test$ cat gcce.c
: #define A 1
: ...................