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.

<strong>C#</strong> LANGUAGE SPECIFICATIONpp-primary-expression::truefalseconditional-symbol( whitespace opt pp-expression whitespace opt )When referenced in a pre-processing expression, a defined conditional compilation symbol has the boolean valuetrue, 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 preprocessingexpression are the same as those for a constant expression (§14.15), except that the only user-definedentities that can be referenced are conditional compilation symbols.9.5.3 Declaration directivesThe declaration directives are used to define or undefine conditional compilation symbols.pp-declaration::whitespace opt # whitespace opt define whitespace conditional-symbol pp-new-linewhitespace opt # whitespace opt undef whitespace conditional-symbol pp-new-linepp-new-line::whitespace opt single-line-comment opt new-lineThe 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 causesthe given conditional compilation symbol to become undefined, starting with the source line that follows thedirective.Any #define and #undef directives in a source file must occur before the first token (§9.4) in the source file;otherwise a compile-time error occurs. In intuitive terms, #define and #undef directives must precede any“real code” in the source file.[Example: The example:#define Enterprise#if Professional || Enterprise#define Advanced#endifnamespace Megacorp.Data{#if Advancedclass PivotTable {...}#endif}is valid because the #define directives precede the first token (the namespace keyword) in the source file.end example][Example: The following example results in a compile-time error because a #define follows real code:end example]#define Anamespace N{#define B#if Bclass Class1 {}#endif}A #define may define a conditional compilation symbol that is already defined, without there being anyintervening #undef for that symbol. [Example: The example below defines a conditional compilation symbol Aand then defines it again.64

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

Saved successfully!

Ooh no, something went wrong!