[Mono-bugs] [Bug 22565] New - #if sections seem not to exclude other preprocessor elements

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
26 Mar 2002 21:21:32 -0000

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by duco@lorentz.xs4all.nl.


--- shadow/22565	Tue Mar 26 16:21:32 2002
+++ shadow/22565.tmp.31519	Tue Mar 26 16:21:32 2002
@@ -0,0 +1,59 @@
+Bug#: 22565
+Product: Mono/MCS
+Version: unspecified
+OS Details: SuSE Linux 7.1
+Status: NEW   
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: duco@lorentz.xs4all.nl               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: #if sections seem not to exclude other preprocessor elements
+Description of Problem:
+When a #if-section is to be excluded, "real" C# code is indeed not
+processed. Other preprocessor elements (such as #warning and #define) are
+happily included 
+Steps to reproduce the problem:
+using System;
+public class Test {
+// Error:
+// #waring and #define are processed, although NOTDEFINED is not defined
+#warning This is a warning
+#define AAA
+#if AAA
+        public static int Number () { return 42; }
+        public static void Main ()
+        {
+                Console.WriteLine ( Number() );
+        }
+Actual Results:
+Compilating yields the warning "This is a warning" and generates an
+executable that prints the number 42.
+Expected Results:
+No warning "This is a warning", as the #warning preprocessor element should
+be excluded by the #if. A compiler error "the name 'Number' does not
+exist", as "AAA" should not be defined so that the definition of 'Number'
+should be excluded.
+How often does this happen?