是否存在处理预处理器指令并提供实际预处理器输出的工具?

发布于 2024-12-25 18:58:31 字数 324 浏览 5 评论 0原文

可能的重复:
预处理器输出

我发现自己在调试 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

断舍离 2025-01-01 18:58:31

在 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.

删除会话 2025-01-01 18:58:31

这正是BoostWave 的创建目的。

Wave C++ 预处理器库是强制 C99/C++ 预处理器功能的符合标准的实现,封装在一个简单易用的界面后面,与标准模板库 (STL) 的众所周知的习惯用法很好地集成。

This is exactly what Boost.Wave was created for.

The Wave C++ preprocessor library is a Standards conformant implementation of the mandated C99/C++ preprocessor functionality packed behind a simple to use interface, which integrates well with the well known idioms of the Standard Template Library (STL).

口干舌燥 2025-01-01 18:58:31

我使用的几乎所有 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 on stdout, see the manpage), on VC++ it's /EP (output to stdout) or /P (output to file).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文