Information Technology Reference
In-Depth Information
Here are some examples illustrating the rules.
No semicolon
↓
#define PremiumVersion // OK
Space before
↓
#define BudgetVersion // OK
# define MediumVersion // OK
↑
Space between
Delimited comments are not allowed.
↓
#define PremiumVersion /* all bells & whistles */
End-of-line comments are fine.
↓
#define BudgetVersion // Stripped-down version
The preprocessor directives are listed in Table 22-1.
Table 22-1.
Preprocessor Directives
Directive
Summary of Meaning
#define
identifier
Defines a compilation symbol.
#undef
identifier
Undefines a compilation symbol.
#if
expression
If the expression is
true
, compiles the following section.
#elif
expression
If the expression is
true
, compiles the following section.
#else
If the previous
#if
or
#elif
expression is
false
, compiles the following
section.
#endif
Marks the end of an
#if
construct.
#region
name
Marks the beginning of a region of code. Has no compilation effect.
#endregion
name
Marks the end of a region of code. Has no compilation effect.
#warning
message
Displays a compile-time warning message.
#error
message
Displays a compile-time error message.
#line
indicator
Changes the line numbers displayed in compiler messages.
#pragma
text
Specifies information about the program context.