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 Turns off line markers in preprocessed output.
-C Preserves comments in preprocessed output.
-D Defines a macro name from the command line, as if in a #define directive.
-dD Emits macro definitions to preprocessed output and prints the output.
-M Generates a rule suitable for the make tool that describes the dependencies of the input file.
-MD 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 file Specifies the file to write the dependencies to. The -MF option must be specified with option -M or -MM.
-MG 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.
-MM 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.
-MMD 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.
-MP Instructs the C preprocessor to add a phony target for each dependency other than the input file.
-MQ target Changes the target of the rule emitted by dependency generation and quotes any characters that are special to the make tool.
-MT target Changes the target of the rule emitted by dependency generation.
-U Undefines a macro name defined by the compiler or by the -D option.