【发布时间】:2014-12-01 20:34:21
【问题描述】:
哪个结果会返回这个构造?我的意思是主函数中的结果变量,为什么? 我知道,这个例子很奇怪;)
header1.h 文件:
extern const int clf_1;
header2.c 文件:
#include "header1.h"
const int clf_1 = 2;
test.h 文件:
#include <header1.h>
#define xyz clf_1
#define NC_CON 2
#if (xyz== NC_CON)
#define test 40
#else
#define test 41
#endif
C 文件
#include <header1.h>
#include <test.h>
int main(int argc,char *argv[])
{
int result = 0:
if (test == 40)
{
result = 40;
}
}
【问题讨论】:
-
运行
gcc -C -E yoursource.c找出答案 -
是的,我做到了,结果是 41,但我预计是 40,因为 xyz == clf_1 和 clf_1 == 2
标签: c if-statement header c-preprocessor ansi