展开#define 等宏后,如何运行 GCC 预处理器以获取代码? [英] How do I run the GCC preprocessor to get the code after macros like #define are expanded?
本文介绍了展开#define 等宏后,如何运行 GCC 预处理器以获取代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
GCC 预处理器是否可以选择生成 C 源代码并过滤掉不相关的源代码?
Is there an option that the GCC preprocessor could generate C source code and filter out irrelevant source code?
例如,.c
文件有一个 #define
开关来定义许多不同的平台.我只对一个平台感兴趣,我希望C预处理器过滤掉不相关的代码.
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.
GCC 支持吗?
推荐答案
是的.使用 -E
选项:
gcc -E foo.c
这篇关于展开#define 等宏后,如何运行 GCC 预处理器以获取代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文