I'm using Visual Studio 2010 C#.
I recently changed all projects in a solution to x64 by using configuration manager in addition to changing the build properties for all projects. Since then, the #if (DEBUG)
directive doesn't work as if the DEBUG constant vanished.
#if (DEBUG)
// This code does not execute even in debug mode!
#endif
I also noticed that instead of the usual bin\Debug
and bin\Release
folders, the projects now get compiled into bin\x64\Debug
and bin\x64\Release
.
I searched around but most related results covered how to configure x64
if it does not show by default.
A compiler directive is a statement that causes the compiler to take a specific action during compilation. Conditional compilation provides a way of including or omitting selected lines of source code depending on the values of literals specified by the DEFINE directive.
A statement written in the source code of a program that lets the programmer instruct the compiler to perform a specific operation within the compilation phase.
Compiler Control Directives These are used to control the compiler actions. C pre=processor offers a feature called as conditional compilation, which can be used to switch on or off based on particular line or group of lines in a program. For example, #ifdef and #ifndef.
Directives specify settings that are used by the page and user-control compilers when the compilers process ASP.NET Web Forms pages (. aspx files) and user control (. ascx) files.
When creating your x64 platform, it's likely your Debug settings for that platform aren't defining the DEBUG
constant.
In the project's Properties, go to your x64/Debug configuration/platform, and check the "Build" tab. There is a check box called: "Define DEBUG constant". Make sure it's checked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With