13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 Lexical structure#if Bvoid H() {}#elsevoid I() {}#endif}results in the exact same sequence of tokens as the programclass C{void F() {}void I() {}}Thus, whereas lexically, the two programs are quite different, syntactically, they are identical. end example]9.5.1 Conditional compilation symbolsThe conditional compilation functionality provided by the #if, #elif, #else, and #endif directives iscontrolled through pre-processing expressions (§9.5.2) and conditional compilation symbols.conditional-symbol::Any identifier-or-keyword except true or falseA conditional compilation symbol has two possible states: defined or undefined. At the beginning of the lexicalprocessing of a source file, a conditional compilation symbol is undefined unless it has been explicitly defined byan external mechanism (such as a command-line compiler option). When a #define directive is processed, theconditional compilation symbol named in that directive becomes defined in that source file. The symbol remainsdefined until an #undef directive for that same symbol is processed, or until the end of the source file is reached.An implication of this is that #define and #undef directives in one source file have no effect on other sourcefiles in the same program.The name space for conditional compilation symbols is distinct and separate from all other named entities in a<strong>C#</strong> program. Conditional compilation symbols can only be referenced in #define and #undef directives and inpre-processing expressions.9.5.2 Pre-processing expressionsPre-processing expressions can occur in #if and #elif directives. The operators !, ==, !=, && and || arepermitted in pre-processing expressions, and parentheses may be used for grouping.pp-expression::whitespace opt pp-or-expression whitespace optpp-or-expression::pp-and-expressionpp-or-expression whitespace opt || whitespace opt pp-and-expressionpp-and-expression::pp-equality-expressionpp-and-expression whitespace opt && whitespace opt pp-equality-expressionpp-equality-expression::pp-unary-expressionpp-equality-expression whitespace opt == whitespace opt pp-unary-expressionpp-equality-expression whitespace opt != whitespace opt pp-unary-expressionpp-unary-expression::pp-primary-expression! whitespace opt pp-unary-expression63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!