/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的代碼和相關代碼,都會是被剝離后的,出現在同一個文件里,這個對于閱讀代碼比較有用。