是否存在处理预处理器指令并提供实际预处理器输出的工具?
可能的重复:
预处理器输出
我发现自己在调试 Android 的 STL 端口。它自始至终使用许多(10-100?)预处理器指令来决定预处理器实际输出哪些代码。很多 #if
和 #ifdef
块。
是否有可用的工具可以运行这些并显示实际发送给编译器的文本?是否可以看到预处理器的输出?
Possible Duplicate:
Preprocessor output
I have found myself debugging STL Port for Android. It uses many (10-100?) preprocessor directives throughout to decide what code is actually output by the preprocessor. Lots of #if
and #ifdef
blocks.
Is there a tool available that can run through these and show what text is actually sent to the compiler? Is it possible to see the output of the preprocessor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 GCC 中,使用
gcc -E source.c
仅显示预处理器的输出。我相信 Clang 也是如此。
对于其他编译器,请参阅手册。这应该被清楚地记录下来。
In GCC, use
gcc -E source.c
to show the output of the preprocessor only.Same for Clang I believe.
For other compilers, see the manual. This should be clearly documented.
这正是Boost。Wave 的创建目的。
This is exactly what Boost.Wave was created for.
我使用的几乎所有 C++ 编译器都有其命令行开关来执行此任务;在 g++ 上,它是
-E
(它将输出写入stdout
,请参阅 联机帮助页),在 VC++ 上是/EP
(输出到stdout
)或/P
(输出到文件)。Almost any C++ compiler I used has its command line switch to perform this task; on g++ it's
-E
(which writes the output onstdout
, see the manpage), on VC++ it's/EP
(output tostdout
) or/P
(output to file).