Wednesday, September 19, 2007

Conditional("DEBUG") and Compiler Optimizations

OK... One interesting aside:


See, how compiler had optimized the ENTIRE constructor away?  This is what is so very powerful.  Because Conditional("DEBUG") statements disappear on a RELEASE build, the compiler is free to optimize your code in ways it sees fit.

The results of compiling with optimizations  turned off:

 c:\>csc /optimize- /t:library ifdebug.cs



Here the compiler preserves your empty constructor.  We'll touch upon these points once again in forthcoming posts.

No comments: