预处理器输出 [英] Preprocessor output

查看:134
本文介绍了预处理器输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在转换为目标文件之前查看 C 预处理器生成的输出?



我想要以查看MACRO定义对我的代码所做的工作。

解决方案

  gcc -E file。 c 

  g ++ -E file.cpp 

会为您做到这一点。 -E开关强制编译器在预处理阶段结束后停止,将当前所有内容吐出到标准输出中。



注意:当然,您必须有一些#include指令。所包含的文件也会被预处理,所以你可能会得到很多输出。



对于Visual C ++,开关是/ E,它将预处理器输出吐出到屏幕上。 >

How do I view the output produced by the C pre-processor, prior to its conversion into an object file?

I want to see what the MACRO definitions do to my code.

解决方案

gcc -E file.c

or

g++ -E file.cpp

will do this for you. The -E switch forces the compiler to stop after the preprocessing phase, spitting all it’s got at the moment to standard output.

Note: Surely you must have some #include directives. The included files get preprocessed, too, so you might get lots of output.

For Visual C++ the switch is /E which spits the preprocessor output to screen.

这篇关于预处理器输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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