Preprocessed *.i file


A preprocessed *.i file is an output of the C or C++ preprocessor. It is usually this extension which is characteristic of files created as the preprocessor output. The preprocessor performs primary transformations of the source program text using only lexical analysis.

The preprocessor carries out the following operations:

  • Inclusion of header files (the '#include' instruction);
  • Macros substitution (the '#define' instruction);
  • Conditional compilation (instructions '#if', '#ifdef', '#else', '#elif', '#endif').

The preprocessor can be used as an auxiliary tool to assist static code analysis. The PVS-Studio static analyzer, for example, can use three different preprocessors (MSVC, Clang, C++Builder), and which of them is chosen to be used for a particular project depends on the type of the project or file. This procedure is necessary because the core of the analyzer is the code parsing library VivaCore that doesn't possess an integrated preprocessor. The necessity of primary preprocessing of source files is determined by the fact that all the instructions '#include' and '#define' should be expanded to enable good static analysis.

You can get a preprocessed file in the MSVC environment by defining the value of the 'Generate Preprocessed File' property on the 'C/C++\Preprocessor' tab as shown in Figure 1.

Picture 1

To get a preprocessed file using the GCC compiler you need to add the parameters '-E -o file_name.i' into its call.

References


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
We use cookies for the analysis of events to improve our content and make user interaction more convenient. By continuing the view of our web-pages you accept the terms of using these files. You can find out more about cookie-files and privacy policy or close the notification, by clicking on the button. Learn More →
Do not show