问题
For some reason, Any code like:
#if DEBUG
CallSomeMethod();
#endif
Is always true regardless of debug or release mode. Any ideas why, and what setting I can use to turn the feature on or off? For the project, define DEBUG constant is set to true.
Thanks.
回答1:
You should be able to select the release mode in your project properties. Right click your project, select Properties and click the build tab on the left of the window. From there, you can uncheck the "define DEBUG constant" box. Make sure you do this for the release build, and not the debug mode.
回答2:
Seems like you're answering your own question:
For the project, define DEBUG constant is set to true.
This should only be set conditionally in the build file, and not always.
回答3:
This will be because the DEBUG
constant is also true for the release mode.
There is nothing special about the build mode - its just a collection of build settings with a name. If you wanted you could create a "Release" mode with all of the normal "Debug" mode settings (and visa versa).
回答4:
When #if DEBUG
, the code will be omitted out to gray scale when you are in release mode, you can see that your self using the visual studio IDE. if that is not the case them maybe like @Kragen suggested that you define DEBUG
somewhere in your class so it affect the release too.
来源:https://stackoverflow.com/questions/6929675/if-debug-always-true-for-debug-and-release-modes