gcc -E -dM 为我提供了预处理器定义,但我希望它能够编译
我有一个很大的源目录,具有复杂的 Makefile 结构(很多包含等)。
我想获取当您运行
gcc -E -dM 时 gcc 将提供的预处理器定义。但是,我也希望构建源代码。当我检查 make/build 日志时,我想查看 make 运行的所有命令,以及传递给编译器和/或覆盖的源中所有文件的 #defines。
我不知道该怎么做。
例如,
如果有一个文件 foo.c 仅包含这一行
#define PI 3.14
运行 gcc -E -dM foo.c 会将所有预处理定义打印到 stdout,以及里面的定义foo.c。
但它无法编译。如何组合命令以使这两种情况发生?
I have a large source directory with a complicated Makefile structure (lots of includes etc.)
I would like to grab the preprocessor defines that gcc will provide when you run
gcc -E -dM. However, I also want the source to be built. And when I check the make/build log, I'd like to see all the commands that were run by make, and ALSO the #defines from all the files in the source that were passed to the compiler and/or overriden.
I'm not sure how to go about this.
For e.g
If had a file foo.c with just this one line
#define PI 3.14
Running gcc -E -dM foo.c will print out all the preprocessory defines to stdout, as well as the define inside foo.c.
But it does not compile. How do I combine commands such that both things happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要分两遍执行此操作,但您可能可以设置一个 makefile 规则来执行此操作,例如用于编译 C 代码:
或者,如果您想将构建和预处理分开,您可以有两个规则,例如
您还需要一个fake target 以确保所有 .c 文件生成 .dump 文件。
You need to do this in two passes, but you can probably set up a makefile rule to do it, e.g. for compiling C code:
Alternatively if you want to separate the build and preprocessing you could have two rules, e.g.
You would also need a fake target to ensure that all the .c files generate .dump files.