Information Technology Reference
In-Depth Information
Using conditional compilation
In theory, conditional compilation is very simple. A typical example looks like this:
#ifdef <some token>
…code to include…
#endif
The token is a general catch-all name for all the available settings, macros, environment variables, and user-
defined flags and values. The challenge with conditional compilation is finding which tokens are available.
Compilers include a range of settings that are defined by the language, platform, compiler, and build. Some
tokens are defined as macros and use a special format: their names are prefixed with a double underscore, and
they may end with another double underscore. Users can define their own custom tokens as absolute values,
references to other settings, or logical combinations of two or more settings.
CAUTION
Note that you can't compare strings in an #if directive, but you can compare tokens with numerical values. You
can also check whether a specific token has been defined.
Table 13.4 lists a small selection of useful macros and platform settings.
Search WWH ::




Custom Search