Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The compiler directive #if does not recognize DEBUG anymore after changing solution to x64

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.

like image 890
Raheel Khan Avatar asked Aug 14 '12 16:08

Raheel Khan


People also ask

Which are compiler directives?

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.

What is a compiler directive in C?

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.

What is compiler control directive?

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.

What is compiler directive in asp net?

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.


1 Answers

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.

like image 76
Reed Copsey Avatar answered Oct 11 '22 20:10

Reed Copsey