How to create a preprocessed file (.i file)

Usually when there's a compiler bug, we will need a testcase. Otherwise we won't be able to find the problem and verify the fix.

Because we won't be able to have the same environment as yours, we will need either a testcase or a preprocessed file (.i file).

Sometimes a small testcase may not always duplicate the problem. And also you may not have the time to create a testcase. So a preprocessed file would work in such case.

Note about a proprocessed file (.i file): it contains all the source code in original .cpp/.c as well as all the needed header files. The compiler (icl or cl) generates the code based on the compile options and include files. So the .i file generated by icl.exe is most likely different than the one generated by cl.exe.

To create a preprocessed file (.i file), just add "-EP -P" to the compile option, and recompile the original .cpp file.  You can also generate a .i file directly from the "Prepocessor" property in Visual Studio*:

  • Right click the file name, and click properties
  • Click Preprocessor\Generate Preprocessed File\Without Line Numbers (/EP /P)

if you recompile from a command window, the .i file will be created under the current directory.

if you recompile from within the Visual Studio* IDE, the .i file will be created under the directory where the original source file is located.

For more complete information about compiler optimizations, see our Optimization Notice.