disable broken tests on net_4_0
[mcs.git] / docs / ecma334 / 9.5.xml
blobbff755c0ec2c9ebcafc8dfb33aacb1ce337994a1
1 <?xml version="1.0"?>
2 <clause number="9.5" title="Pre-processing directives">
3   <paragraph>The pre-processing directives provide the ability to conditionally skip sections of source files, to report error and warning conditions, and to delineate distinct regions of source code. <note>[Note: The term &quot;pre-processing directives&quot; is used only for consistency with the C and C++ programming languages. In C#, there is no separate pre-processing step; pre-processing directives are processed as part of the lexical analysis phase. end note]</note> <grammar_production><name><non_terminal where="9.5">pp-directive</non_terminal></name> :: <rhs><non_terminal where="9.5.3">pp-declaration</non_terminal></rhs><rhs><non_terminal where="9.5.4">pp-conditional</non_terminal></rhs><rhs><non_terminal where="9.5.7">pp-line</non_terminal></rhs><rhs><non_terminal where="9.5.5">pp-diagnostic</non_terminal></rhs><rhs><non_terminal where="9.5.6">pp-region</non_terminal></rhs></grammar_production></paragraph>
4   <paragraph>The following pre-processing directives are available: <list><list_item><symbol>#define</symbol> and <symbol>#undef</symbol>, which are used to define and undefine, respectively, conditional compilation symbols (<hyperlink>9.5.3</hyperlink>). </list_item><list_item><symbol>#if</symbol>, <symbol>#elif</symbol>, <symbol>#else</symbol>, and <symbol>#endif</symbol>, which are used to conditionally skip sections of source code (<hyperlink>9.5.1</hyperlink>). </list_item><list_item><symbol>#line</symbol>, which is used to control line numbers emitted for errors and warnings (<hyperlink>9.5.7</hyperlink>). </list_item><list_item><symbol>#error</symbol> and <symbol>#warning</symbol>, which are used to issue errors and warnings, respectively (<hyperlink>9.5.5</hyperlink>). </list_item><list_item><symbol>#region</symbol> and <symbol>#endregion</symbol>, which are used to explicitly mark sections of source code (<hyperlink>9.5.6</hyperlink>). </list_item></list></paragraph>
5   <paragraph>A pre-processing directive always occupies a separate line of source code and always begins with a # character and a pre-processing directive name. White space may occur before the # character and between the # character and the directive name. </paragraph>
6   <paragraph>A source line containing a <symbol>#define</symbol>, <symbol>#undef</symbol>, <symbol>#if</symbol>, <symbol>#elif</symbol>, <symbol>#else</symbol>, <symbol>#endif</symbol>, or <symbol>#line</symbol> directive may end with a single-line comment. Delimited comments (the /* */ style of comments) are not permitted on source lines containing pre-processing directives. </paragraph>
7   <paragraph>Pre-processing directives are not tokens and are not part of the syntactic grammar of C#. However,  pre-processing directives can be used to include or exclude sequences of tokens and can in that way affect the meaning of a C# program. <example>[Example: For example, when compiled, the program <code_example><![CDATA[
8 #define A  
9 #undef B  
10 class C  
11 {  
12    #if A  
13    void F() {}  
14    #else  
15    void G() {}  
16    #endif  
17    #if B  
18    void H() {}  
19    #else  
20    void I() {}  
21    #endif  
22 }  
23 ]]></code_example>results in the exact same sequence of tokens as the program <code_example><![CDATA[
24 class C  
25 {  
26    void F() {}  
27    void I() {}  
28 }  
29 ]]></code_example></example></paragraph>
30   <paragraph>
31     <example>Thus, whereas lexically, the two programs are quite different, syntactically, they are identical. end example]</example>
32   </paragraph>
33 </clause>