如何查看 Visual C++ 预处理器的输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8978997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I see the output of the Visual C++ preprocessor?
提问by Benjamin Pollack
I want to see the output of the Visual C++ Preprocessor on my code -- i.e., the equivalent of gcc -E
. For the life of me, I cannot find the relevant compiler switch. How do I accomplish this?
我想在我的代码上看到 Visual C++ 预处理器的输出——即,相当于gcc -E
. 对于我的生活,我找不到相关的编译器开关。我该如何实现?
采纳答案by Abhijeet Rastogi
cl.exe
, the command line interface to Microsoft Visual C++, has three different options for outputting the preprocessed file (hence the inconsistency in the previous responses about Visual C++):
cl.exe
,Microsoft Visual C++ 的命令行界面,具有三个不同的输出预处理文件的选项(因此与之前关于 Visual C++ 的响应不一致):
/E
: preprocess to stdout(similar to GCC's -E option)/P
: preprocess to file/EP
: preprocess to stdout without #line directives
/E
:预处理到标准输出(类似于 GCC 的 -E 选项)/P
:预处理到文件/EP
:在没有#line 指令的情况下预处理到标准输出
(copied directly from https://stackoverflow.com/a/277362/3279)
回答by Xeo
Project properties -> C/C++ -> Preprocessing -> Preprocess to a file: Yes (/P)
项目属性 -> C/C++ -> Preprocessing -> Preprocess to a file: Yes (/P)
The files will be called .i and will be created in the build directory.
这些文件将被称为 .i 并将在构建目录中创建。
Also see the msdn page.
另请参阅msdn 页面。