GCC预处理器 [英] GCC preprocessor
问题描述
可能存在重复:
运行GCC预处理器
是否有 GCC 选项使GCC预处理器生成 C 源代码但过滤掉不相关的源代码?
例如,一个 C 文件具有 #define switch
来定义许多不同的平台。我只在一个平台上使用,所以我希望 C 预处理器过滤出不相关的代码。 GCC是否支持此功能?
使用 gcc -E
预处理器部分,例如给文件 in.c
#if 0
0;
#endif
#if 1
1;
#endif
运行中
$ gcc -E in.c -o in.i
产生一个文件 in.i
#1in.cpp
#1<内置>
#1< command-line>
#1in.cpp
1;
即 #if 0
后面的部分被删除。如果你有 #include
'd文件,它们也会被粘贴,所以我不确定这有多大帮助。
Possible Duplicate:
Running the GCC preprocessor
Is there a GCC option to make the GCC preprocessor generate C source code but filter out irrelevant source code?
For example, a C file has #define switch
to define for many different platforms. I'm only intersted in one platform, so I want the C preprocessor to filter out unrelated code. Does GCC support this?
Use gcc -E
to only run the preprocessor part, e.g. give a file in.c
#if 0
0;
#endif
#if 1
1;
#endif
running
$ gcc -E in.c -o in.i
yields a file in.i
# 1 "in.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "in.cpp"
1;
i.e. the parts behind the #if 0
got removed. If you would have #include
'd files they would have been pasted too though, so I am not sure how much help this is.
这篇关于GCC预处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!