The C preprocessor provides four separate facilities that you can use as you see fit:
C preprocessors vary in some details. For a full explanation of the GNU C preprocessor, see the info file `cpp.info ', or the manual The C Preprocessor . Both of these are built from the same documentation source file, `cpp.texinfo '. The GNU C preprocessor provides a superset of the features of ANSI Standard C.
ANSI Standard C requires the rejection of many harmless constructs commonly used by today's C programs. Such incompatibility would be inconvenient for users, so the GNU C preprocessor is configured to accept these constructs by default. Strictly speaking, to get ANSI Standard C, you must use the options `-trigraphs ', `-undef ' and `-pedantic ', but in practice the consequences of having strict ANSI Standard C make it undesirable to do this.
Most often when you use the C preprocessor you will not have to invoke it explicitly: the C compiler will do so automatically. However, the preprocessor is sometimes useful individually.
When you call the preprocessor individually, either name (cpp or cccp ) will do they are completely synonymous.
The C preprocessor expects two file names as arguments, infile and
outfile . The preprocessor reads infile together with any other files it specifies with `#include '. All the output generated by the combined input files is written in outfile .
Either infile or outfile may be `- ', which as infile
means to read from standard input and as outfile means to write to standard output. Also, if outfile or both file names are omitted, the standard output and standard input are used for the omitted file names.
You don't want to know any more about trigraphs.
Add the directory directory to the end of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. If you use more than one `-I ' option, the directories are scanned in left-to-right order; the standard system directories come after.
If additional directories are specified with `-I ' options after the `-I- ', these directories are searched for all `#include ' directives.
In addition, the `-I- ' option inhibits the use of the current directory as the first search directory for `#include file "'. Therefore, the current directory is searched only if it is requested explicitly with `-I. '. Specifying both `-I- ' and `-I. ' allows you to control precisely which directories are searched before the current one and which are searched after.
Predefine name as a macro, with definition `1 '.
Predefine name as a macro, with definition definition . There are no restrictions on the contents of definition , but if you are invoking the preprocessor from a shell or shell-like program you may need to use the shell's quoting syntax to protect characters such as spaces that have a meaning in the shell syntax. If you use more than one `-D ' for the same name , the rightmost definition takes effect.
Do not predefine name . If both `-U ' and `-D ' are specified for one name, the `-U ' beats the `-D ' and the name is not predefined.
You can use `-A- ' to disable all predefined assertions; it also undefines all predefined macros.
touch foo.h; cpp -dM foo.h
will show the values of any predefined macros.
`-MG ' says to treat missing header files as generated files and assume they live in the same directory as the source file. It must be specified in addition to `-M '.
This feature is used in automatic updating of makefiles.
When invoking gcc, do not specify the `file ' argument. Gcc will create file names made by replacing `.c ' with `.d ' at the end of the input file names.
In Mach, you can use the utility md to merge multiple files into a single dependency file suitable for using with the `make ' command.
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. The preprocessor evaluates any `-D ' and `-U ' options on the command line before processing `-imacros file ' .
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).
Specify prefix as the prefix for subsequent `-iwithprefix ' options.
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 '.
These options are generated by the compiler driver gcc , but not passed from the `gcc ' command line.
This option is available only when you call cpp directly;
gcc will not pass it from its command line.
This option is available only when you call cpp directly; gcc will not pass it from its command line.
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.