Developer Documentation
PATH  Mac OS X Documentation > Developer Tools > The GNU C Preprocessor


Previous | Contents | Next

The GNU C preprocessor ( cpp ) is a macro processor the C compiler uses to transform your program before actual compilation. It's called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs.

The C preprocessor provides the following four facilities:

C preprocessors vary in their implementation details. This section describes the GNU C preprocessor, which provides a superset of the features of ANSI-standard C.

Mac OS X actually includes two preprocessors: the standard GNU C preprocessor ( cpp ) and the precompilation preprocessor ( cpp-precomp ). The two preprocessors are largely similar, except for some rarely used extensions. The precompilation preprocessor ( cpp-precomp ) is the default preprocessor for C and Objective-C code. The standard preprocessor ( cpp ) is the default preprocessor for C++ and Objective-C++ code. To switch to the standard preprocessor ( cpp ) on platforms on which precompiled headers are available, use the -traditonal-cpp flag on cpp the command line.

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 C preprocessor is configured to accept these constructs by default. To get ANSI-standard C you would use the options -trigraphs , -undef , and -pedantic , although in practice the consequences of having strict ANSI Standard C may make it undesirable to do this. See the section " See Invoking the C Preprocessor " for more information.

Global Transformations

Preprocessor Commands

Header Files

Precompiled Header Files

Macros

Conditionals

Pragmas

Combining Source Files

C Preprocessor Output

Invoking the C Preprocessor


The GNU C Preprocessor

Previous | Contents | Next