This question already has an answer here:
这个问题在这里已有答案:
- How do I see a C/C++ source file after preprocessing in Visual Studio? 10 answers
在Visual Studio中预处理后如何查看C / C ++源文件? 10个答案
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。对于我的生活,我找不到相关的编译器开关。我该如何做到这一点?
2 个解决方案
#1
16
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:预处理到stdout(类似于GCC的-E选项)
/ P:预处理到文件
/ EP:没有#line指令的stdout预处理
(copied directly from https://*.com/a/277362/3279)
(直接从https://*.com/a/277362/3279复制)
#2
23
Project properties -> C/C++ -> Preprocessing -> Preprocess to a file: Yes (/P)
项目属性 - > C / C ++ - >预处理 - >预处理到文件:是(/ P)
Also see the msdn page.
另请参阅msdn页面。
#1
16
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:预处理到stdout(类似于GCC的-E选项)
/ P:预处理到文件
/ EP:没有#line指令的stdout预处理
(copied directly from https://*.com/a/277362/3279)
(直接从https://*.com/a/277362/3279复制)
#2
23
Project properties -> C/C++ -> Preprocessing -> Preprocess to a file: Yes (/P)
项目属性 - > C / C ++ - >预处理 - >预处理到文件:是(/ P)
Also see the msdn page.
另请参阅msdn页面。