如何查看 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 19:25:16  来源:igfitidea点击:

How can I see the output of the Visual C++ preprocessor?

c++visual-c++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++ 的响应不一致):

(copied directly from https://stackoverflow.com/a/277362/3279)

(直接复制自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 页面