在gcc包含了C程序的所有头文件之后,如何输出中间文件? [英] How to output the intermediate file after gcc has included all header files for a C program?

查看:231
本文介绍了在gcc包含了C程序的所有头文件之后,如何输出中间文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在典型的C程序中,我将其分解为几个组件:

In a typical C program, I break down it into several components:

// main.c
#include 'part-a.h'
#include 'part-b.h'

main () {
// ...
}

// part-a.h
#include 'part-c.h'
// ...

我想以递归方式将整个项目导出为一个文件,包括每个依赖项(不包括标准库),我如何使用gcc做到这一点?

I want to export the whole project as one file including every dependencies recursively (excluding standard libraries), how could I do that with gcc?

推荐答案

gcc -E加上通常用于编译的所有其他选项,而没有-c.这将产生预处理器输出.这是您所能得到的最好的,AFAIK无法仅扩展#include指令.但是您可以使用一些预处理程序库(GCC和Boost具有一个)来编写您自己的工具.

gcc -E plus all the other option you normally use to compile, without -c. This will produce preprocessor output. It's the best you can get, AFAIK there's no way to only expand #include directives. But you can use some preprocessor library (GCC and Boost have ones) to write your own tool.

http://www.boost.org/doc/libs/1_54_0 /libs/wave/

这篇关于在gcc包含了C程序的所有头文件之后,如何输出中间文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆