• 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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
evilrixSenior 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Challenges in Government Cyber Security

Has cyber security been a challenge in your government organization? Are you looking to improve your government's network security? Learn more about how to improve your government organization's security by viewing our on-demand webinar!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.