-E

Description

Instructs the compiler to preprocess the source files named in the compiler invocation and creates an output preprocessed source file.

Syntax

Read syntax diagramSkip visual syntax diagram>>- -E---------------------------------------------------------><

Notes

The -E and -P options have different results. When the -E option is specified, the compiler assumes that the input is a C or C++ file and that the output will be recompiled or reprocessed in some way. These assumptions are:

The -P option is used for general-purpose preprocessing. No assumptions are made concerning the input or the intended use of the output. This mode is intended for use with input files that are not written in C or C++. As such, all preprocessor-specific constructs are processed as described in the ANSI C standard. In this case, the continuation sequence is removed as described in the "Phases of Translation" of that standard. All non-preprocessor-specific text should be output as it appears.

Using -E causes #line directives to be generated to preserve the source coordinates of the tokens. Blank lines are stripped and replaced by compensating #line directives.

The line continuation sequence is removed and the source lines are concatenated with the -P option. With the -E option, the tokens are output on separate lines in order to preserve the source coordinates. The continuation sequence may be removed in this case.

The -E option overrides the -P, -o, and -qsyntaxonly options, and accepts any file name.

If used with the -M option, -E will work only for files with a .C, .cpp, .cc (all C++ source files), .c (C source files), or a .i (preprocessed source files) filename suffix. Source files with unrecognized filename suffixes are treated and preprocessed as C files, and no error message is generated.

Unless -C is specified, comments are replaced in the preprocessed output by a single space character. New lines and #line directives are issued for comments that span multiple source lines, and when -C is not specified. Comments within a macro function argument are deleted.

Example

To compile myprogram.C and send the preprocessed source to standard output, enter:

xlc++ myprogram.C -E

If myprogram.C has a code fragment such as:

#define SUM(x,y) (x + y) ;
int a ;
#define mm 1 ; /* This is a comment in a
                  preprocessor directive */
int b ;        /* This is another comment across
                  two lines */
int c ;
               /* Another comment */
c = SUM(a, /* Comment in a macro function argument*/
        b) ;

the output will be:

#line 2 "myprogram.C"
int a;
#line 5
int b;
 
int c;
 
c =
(a + b);

Related information