[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11 Options Controlling the Preprocessor

These options control the C preprocessor, which is run on each C source file before actual compilation.

If you use the `-E' option, nothing is done except preprocessing. Some of these options make sense only together with `-E' because they cause the preprocessor output to be unsuitable for actual compilation.

-include file
Process file as input before processing the regular input file. In effect, the contents of file are compiled first. Any `-D' and `-U' options on the command line are always processed before `-include file', regardless of the order in which they are written. All the `-include' and `-imacros' options are processed in the order in which they are written.

-imacros file
Process file as input, discarding the resulting output, before processing the regular input file. Because the output generated from file is discarded, the only effect of `-imacros file' is to make the macros defined in file available for use in the main input. All the `-include' and `-imacros' options are processed in the order in which they are written.

-idirafter dir
Add the directory dir to the second include path. The directories on the second include path are searched when a header file is not found in any of the directories in the main include path (the one that `-I' adds to).

-iprefix prefix
Specify prefix as the prefix for subsequent `-iwithprefix' options.

-iwithprefix dir
Add a directory to the second include path. The directory's name is made by concatenating prefix and dir, where prefix was specified previously with `-iprefix'. If you have not specified a prefix yet, the directory containing the installed passes of the compiler is used as the default.

-iwithprefixbefore dir
Add a directory to the main include path. The directory's name is made by concatenating prefix and dir, as in the case of `-iwithprefix'.

-isystem dir
Add a directory to the beginning of the second include path, marking it as a system directory, so that it gets the same special treatment as is applied to the standard system directories.

-nostdinc
Do not search the standard system directories for header files. Only the directories you have specified with `-I' options (and the current directory, if appropriate) are searched. See section 3.14 Options for Directory Search, for information on `-I'.

By using both `-nostdinc' and `-I-', you can limit the include-file search path to only those directories you specify explicitly.

-remap
When searching for a header file in a directory, remap file names if a file named `header.gcc' exists in that directory. This can be used to work around limitations of file systems with file name restrictions. The `header.gcc' file should contain a series of lines with two tokens on each line: the first token is the name to map, and the second token is the actual name to use.

-undef
Do not predefine any nonstandard macros. (Including architecture flags).

-E
Run only the C preprocessor. Preprocess all the C source files specified and output the results to standard output or to the specified output file.

-C
Tell the preprocessor not to discard comments. Used with the `-E' option.

-P
Tell the preprocessor not to generate `#line' directives. Used with the `-E' option.

-M
Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files. Unless overridden explicitly, the object file name consists of the basename of the source file with any suffix replaced with object file suffix. If there are many included files then the rule is split into several lines using `\'-newline.

`-M' implies `-E'.

-MM
Like `-M', but mention only the files included with `#include "file"'. System header files included with `#include <file>' are omitted.

-MD
Like `-M' but the dependency information is written to a file rather than stdout. gcc will use the same file name and directory as the object file, but with the suffix `.d' instead.

This is in addition to compiling the main file as specified---`-MD' does not inhibit ordinary compilation the way `-M' does, unless you also specify `-MG'.

With Mach, you can use the utility md to merge multiple dependency files into a single dependency file suitable for using with the `make' command.

-MMD
Like `-MD' except mention only user header files, not system -header files.

-MF file
When used with `-M' or `-MM', specifies a file to write the dependencies to. This allows the preprocessor to write the preprocessed file to stdout normally. If no `-MF' switch is given, CPP sends the rules to stdout and suppresses normal preprocessed output.

Another way to specify output of a make rule is by setting the environment variable DEPENDENCIES_OUTPUT (see section 3.19 Environment Variables Affecting GCC).

-MG
When used with `-M' or `-MM', `-MG' says to treat missing header files as generated files and assume they live in the same directory as the source file. It suppresses preprocessed output, as a missing header file is ordinarily an error.

This feature is used in automatic updating of makefiles.

-MP
This option instructs CPP to add a phony target for each dependency other than the main file, causing each to depend on nothing. These dummy rules work around errors make gives if you remove header files without updating the Makefile to match.

This is typical output:-

 
/tmp/test.o: /tmp/test.c /tmp/test.h

/tmp/test.h:

-MQ target
-MT target
By default CPP uses the main file name, including any path, and appends the object suffix, normally ".o", to it to obtain the name of the target for dependency generation. With `-MT' you can specify a target yourself, overriding the default one.

If you want multiple targets, you can specify them as a single argument to `-MT', or use multiple `-MT' options.

The targets you specify are output in the order they appear on the command line. `-MQ' is identical to `-MT', except that the target name is quoted for Make, but with `-MT' it isn't. For example, `-MT '$(objpfx)foo.o'' gives

 
$(objpfx)foo.o: /tmp/foo.c

but `-MQ '$(objpfx)foo.o'' gives

 
$$(objpfx)foo.o: /tmp/foo.c

The default target is automatically quoted, as if it were given with `-MQ'.

-H
Print the name of each header file used, in addition to other normal activities.

-Aquestion(answer)
Assert the answer answer for question, in case it is tested with a preprocessing conditional such as `#if #question(answer)'. `-A-' disables the standard assertions that normally describe the target machine.

-Dmacro
Define macro macro with the string `1' as its definition.

-Dmacro=defn
Define macro macro as defn. All instances of `-D' on the command line are processed before any `-U' options.

Any `-D' and `-U' options on the command line are processed in order, and always before `-imacros file', regardless of the order in which they are written.

-Umacro
Undefine macro macro. `-U' options are evaluated after all `-D' options, but before any `-include' and `-imacros' options.

Any `-D' and `-U' options on the command line are processed in order, and always before `-imacros file', regardless of the order in which they are written.

-dM
Tell the preprocessor to output only a list of the macro definitions that are in effect at the end of preprocessing. Used with the `-E' option.

-dD
Tell the preprocessing to pass all macro definitions into the output, in their proper sequence in the rest of the output.

-dN
Like `-dD' except that the macro arguments and contents are omitted. Only `#define name' is included in the output.

-dI
Output `#include' directives in addition to the result of preprocessing.

-fpreprocessed
Indicate to the preprocessor that the input file has already been preprocessed. This suppresses things like macro expansion, trigraph conversion, escaped newline splicing, and processing of most directives. The preprocessor still recognizes and removes comments, so that you can pass a file preprocessed with `-C' to the compiler without problems. In this mode the integrated preprocessor is little more than a tokenizer for the front ends.

`-fpreprocessed' is implicit if the input file has one of the extensions `i', `ii' or `mi'. These are the extensions that GCC uses for preprocessed files created by `-save-temps'.

-trigraphs
Process ISO standard trigraph sequences. These are three-character sequences, all starting with `??', that are defined by ISO C to stand for single characters. For example, `??/' stands for `\', so `'??/n'' is a character constant for a newline. By default, GCC ignores trigraphs, but in standard-conforming modes it converts them. See the `-std' and `-ansi' options.

The nine trigraph sequences are

`??('
-> `['

`??)'
-> `]'

`??<'
-> `{'

`??>'
-> `}'

`??='
-> `#'

`??/'
-> `\'

`??''
-> `^'

`??!'
-> `|'

`??-'
-> `~'

Trigraph support is not popular, so many compilers do not implement it properly. Portable code should not rely on trigraphs being either converted or ignored.

-Wp\,option
Pass option as an option to the preprocessor. If option contains commas, it is split into multiple options at the commas.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Charlie & on June, 17 2001 using texi2html