Preprocessing
Preprocessing manipulates the text of a source file, usually as a first phase of translation that is initiated by a compiler invocation. Common tasks accomplished by preprocessing are macro substitution, testing for conditional compilation directives, and file inclusion.
You can invoke the preprocessor separately to process text without compiling. The output is an intermediate file, which can be input for subsequent translation. Preprocessing without compilation can be useful as a debugging aid because it provides a way to see the result of include directives, conditional compilation directives, and complex macro expansions.
The following table lists the options that direct the operation of the preprocessor.
Option | Description |
---|---|
-E | Preprocesses the source files and writes the output to standard output. By default, #line directives are generated. |
-P | Preprocesses the source files and creates an intermediary file with a .i file name suffix for each source file. By default, #line directives are not generated. |
-C, -C! | Preserves comments in preprocessed output. |
-D | Defines a macro name from the command line, as if in a #define directive. |
-dD1 | Emits macro definitions to preprocessed output and prints the output. |
-dM (-qshowmacros)1 | Emits macro definitions to preprocessed output. |
-qmakedep, -MD (-qmakedep=gcc) | Produces the dependency files that are used by the make tool for each source file. |
-M1 | Generates a rule suitable for the make tool that describes the dependencies of the input file. |
-MD1 | Compiles the source files, generates the object file, and generates a rule suitable for the make tool that describes the dependencies of the input file in a .d file with the name of the input file. |
-MF file1 | Specifies the file to write the dependencies to. The -MF option must be specified with option -M or -MM. |
-MG1 | Assumes that missing header files are generated files and adds them to the dependency list without raising an error. The -MG option must be used with option -M, -MD, -MM, or -MMD. |
-MM1 | Generates a rule suitable for the make tool that describes the dependencies of the input file, but does not mention header files that are found in system header directories nor header files that are included from such a header. |
-MMD1 | Compiles the source files, generates the object file, and generates a rule suitable for the make tool that describes the dependencies of the input file in a .d file with the name of the input file. However, the dependencies do not include header files that are found in system header directories nor header files that are included from such a header. |
-MP1 | Instructs the C preprocessor to add a phony target for each dependency other than the input file. |
-MQ target1 | Changes the target of the rule emitted by dependency generation and quotes any characters that are special to the make tool. |
-MT target1 | Changes the target of the rule emitted by dependency generation. |
-U | Undefines a macro name defined by the compiler or by the -D option. |
Note:
|