Preprocessing Only in ANSI C and C++
filed in Personal on Feb.04, 2010
Use the -E, -P or -EP option to preprocess your source files without compiling them. When using these options, only the preprocessing phase of compilation is activated.
Using -E
When you specify the -E option, the compiler’s preprocessor expands your source module and writes the result to stdout. The preprocessed source contains #line directives, which the compiler uses to determine the source file and line number. For example, to preprocess two source files and write them to stdout, enter the following command:
- cc -E prog1.c prog2.c
- cc -E prog1.c prog2.c
Using -P
When you specify the -P option, the preprocessor expands your source module and directs the output to a .i file instead of stdout. Unlike the -E option, the output from -P does not include #line number directives. By default, the preprocessor creates the name of the output file using the prefix of the source file name with a .i extension. You can change this by using the -ofile option. For example, the following command creates two files named prog1.i and prog2.i, which you can use as input to another compilation:
- cc -P prog1.c prog2.c
- cc -P prog1.c prog2.c
!!! Caution !!!
When you use the -P option, any existing files with the same name and extension are overwritten.
Using -EP
Using the -EP option directs the preprocessor to not include #line directives in the output. -EP is equivalent to -E -P.
- IA-32 Systems: prompt>icc -EP prog1.c prog2.c
- Itanium?-based Systems: prompt>ecc -EP prog1.c prog2.c
Preserving Comments in Preprocessed Source Output
Use the -C option to preserve comments in your preprocessed source output. Comments following preprocessing directives, however, are not preserved.
Source: http://www.strw.leidenuniv.nl/docs/intel/c_ug/linux313.htm