Reputation: 310
I have a method that sets up some Debug only configurations, I have used this pattern on a few projects and with some of them it seems that nor #if DEBUG nor Conditional("DEBUG") are omitted in my release build.
Any ideas why?
Define DEBUG constant is checked:
Upvotes: 1
Views: 980
Reputation: 310
Something that may be obvious for some: the Build configuration changes based on the selected Configuration (eg. Debug) and Platform (eg. Any CPU).
In order to have #if DEBUG and Conditional("DEBUG") working as expected, the DEBUG constant must be defined in the 'Debug' configuration only!
Notice the difference:
If DEBUG is defined in Release, when using #if DEBUG or Conditional("DEBUG"), the condition will return true because the DEBUG constant exists in the project configuration.
Upvotes: 0
Reputation: 21003
As stated by @Evk, ""Define DEBUG constant" is checked. You need to uncheck it".
That defines DEBUG for the preprocessor even if it is not in the text box above it
Upvotes: 2