C Preprocessor

If you're careful, it's possible (and can be useful) to use #include within a header file, so that you end up with ``nested header files.''

It's possible to use #define to define ``function-like'' macros that accept arguments; the expansion of the macro can therefore depend on the arguments it's ``invoked'' with.

Two special preprocessing operators # and ## let you control the expansion of macro arguments in fancier ways.

The preprocessor directive #if lets you conditionally include (or, with #else, conditionally not include) a section of code depending on some arbitrary compile-time expression. (#if can also do the same macro-definedness tests as #ifdef and #ifndef, because the expression can use a defined() operator.)

Other preprocessing directives are #elif, #error, #line, and #pragma.

There are a few predefined preprocessor macros, some required by the C standard, others perhaps defined by particular compilation environments. These are useful for conditional compilation (#ifdef, #ifndef).

Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995, 1996 // mail feedback