X hits on this document

768 views

0 shares

0 downloads

0 comments

60 / 396

Chapter ‎18   Unsafe code

requirement that conditional compilation symbols be explicitly declared before they are referenced in pre-processing expressions. Instead, undeclared symbols are simply undefined and thus have the value false.

The name space for conditional compilation symbols is distinct and separate from all other named entities in a C# program. Conditional compilation symbols can only be referenced in #define and #undef directives and in pre-processing expressions.

2.5.2 Pre-processing expressions

Pre-processing expressions can occur in #if and #elif directives. The operators !, ==, !=, && and || are permitted in pre-processing expressions, and parentheses may be used for grouping.

pp-expression: whitespaceopt   pp-or-expression   whitespaceopt

pp-or-expression: pp-and-expression pp-or-expression   whitespaceopt   ||   whitespaceopt   pp-and-expression

pp-and-expression: pp-equality-expression pp-and-expression   whitespaceopt   &&   whitespaceopt   pp-equality-expression

pp-equality-expression: pp-unary-expression pp-equality-expression   whitespaceopt   ==   whitespaceopt   pp-unary-expression pp-equality-expression   whitespaceopt   !=   whitespaceopt   pp-unary-expression

pp-unary-expression: pp-primary-expression !   whitespaceopt   pp-unary-expression

pp-primary-expression: true false conditional-symbol (   whitespaceopt   pp-expression   whitespaceopt   )

When referenced in a pre-processing expression, a defined conditional compilation symbol has the boolean value true, and an undefined conditional compilation symbol has the boolean value false.

Evaluation of a pre-processing expression always yields a boolean value. The rules of evaluation for a pre-processing expression are the same as those for a constant expression (§‎7.15), except that the only user-defined entities that can be referenced are conditional compilation symbols.

2.5.3 Declaration directives

The declaration directives are used to define or undefine conditional compilation symbols.

pp-declaration: whitespaceopt   #   whitespaceopt   define   whitespace   conditional-symbol   pp-new-line whitespaceopt   #   whitespaceopt   undef   whitespace   conditional-symbol   pp-new-line

pp-new-line: whitespaceopt   single-line-commentopt   new-line

The processing of a #define directive causes the given conditional compilation symbol to become defined, starting with the source line that follows the directive. Likewise, the processing of an #undef directive causes the given conditional compilation symbol to become undefined, starting with the source line that follows the

Copyright Microsoft Corporation 1999-2003. All Rights Reserved.47

Document info
Document views768
Page views768
Page last viewedSat Dec 03 03:22:17 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments