/P (Preprocess to a File)
Home | Overview | How Do I | Compiler Options
This option writes preprocessor output to a file with the same base name as the source file, but with the .I extension. It adds #line directives to the output file at the beginning and end of each included file and around lines removed by preprocessor directives that specify conditional compilation. The preprocessed listing file is identical to the original source file, except that all preprocessor directives are carried out, and macro expansions are performed.
This option suppresses compilation; CL does not produce an .OBJ file, even if the /Fo option is specified. The /P option also suppresses production of the alternate output files created by the /FA, /Fa, or /Fm option.
The /P option is similar to the /E and /EP options. Using /EP with /P suppresses placement of #line directives in the output file.
The following table summarizes the actions of the /E, /EP, and /P options.
Option | Preprocessor output includes #line directives? | Output sent to |
/E | Yes | stdout |
/P | Yes | .i file |
/EP | No | stdout |
/E /EP | No | stdout |
/P /EP | No | .i file |
Send feedback to MSDN. Look here for MSDN Online resources.
1、一般用/P /EP,这样就没有#line了,生成的是.i文件
2、利用这个,可以看有很多复杂宏,预编译之后的源代码,比如stl, boost等,#include的代码和相关代码,都会是被剥离后的,出现在同一个文件里,这个对于阅读代码比较有用。