• C

else section of #if DEBUG is dimmed


Why is the #else section dimmed?

 
string mystring = "";
        #if DEBUG
            //code that will run in debug mode
         mystring = "abc";
        #else
            //code that will run in release mode
         mystring = "def";
        #endif

Open in new window

DovbermanAsked:
Who is Participating?
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
>> How do I know if the dimmed area is reachable?
Well, if you have DEBUG defined then the if part will be compiled in and the else part compiled out. If DEBUG is not defined then it'll be the converse of that. Note that DEBUG might be defined in the project settings and not in your code.
0
 
evilrixSenior Software Engineer (Avast)Commented:
I presume you are using an IDE such a Visual Studio? The area that's dimmed is the area that is generally excluded from compilation by the precompiler.
0
 
DovbermanAuthor Commented:
Yes, I am using Visual Studio 2008.

How do I know if the dimmed area is reachable?

0
Firewall Management 201 with Professor Wool

In this whiteboard video, Professor Wool highlights the challenges, benefits and trade-offs of utilizing zero-touch automation for security policy change management. Watch and Learn!

 
DovbermanAuthor Commented:
The else code is not reached.

Does this mean that I need to change the Build settings?      

  #if DEBUG
                 //code that will run in debug mode
                 strAppPath = Application.StartupPath + "\\..\\..\\Images";
                 txtTest.Text = "Debug Mode";
        #else
                    //code that will run in release mode
                   strAppPath = Application.StartupPath + "\\Images";
                   txtTest.Text = "Release Mode";
#endif
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> Does this mean that I need to change the Build settings?      
It would suggest that somewhere DEBUG is defined. Check your project settings. Also, if you are building with Visual Studio it's probably as simple as choosing the Release build configuration rather than the Debug configuration (Visual Studio projects generally contain the ability to build both configurations).

http://msdn.microsoft.com/en-us/library/wx0123s5(v=vs.90).aspx
0
 
DovbermanAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.