如何在运行GCC预处理器以获取像#define这样的宏之后的代码? [英] How do I run the GCC preprocessor to get the code after macros like #define are expanded?
本文介绍了如何在运行GCC预处理器以获取像#define这样的宏之后的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个选项,GCC预处理器可以生成C源代码并过滤出不相关的源代码?
例如,一个 .c
文件有一个 #define
开关可以为许多不同的平台定义。我只对一个平台感兴趣,并且我希望C预处理器过滤出无关的代码。
GCC 是否支持这项功能?
解决方案
是的。使用 -E
选项:
gcc -E foo.c
Is there an option that the GCC preprocessor could generate C source code and filter out irrelevant source code?
For example, a .c
file has a #define
switch to define for many different platforms. I'm only interested in one platform, and I want the C preprocessor to filter out unrelated code.
Does GCC support this?
解决方案
Yes. Use the -E
option:
gcc -E foo.c
这篇关于如何在运行GCC预处理器以获取像#define这样的宏之后的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文