barssala
barssala

Reputation: 483

#ifdef _DEBUG release mode in vs 2008

There are some part of my project which don't function in release mode. I can check it by using printf and it doesn't print anything. I'll show you in this following code:

void SNKsomething::vGetState()
{
#ifdef SNK_STH
for(int i = 0; i < 2; i++)
{
printf("sth\n');
}

Additionally, SNK_STH is defined in files Globals.h as following

#ifdef _DEBUG // in Project properties
#define SNK_STH
#else
// .....

So, I don't see sth which I print it in release mode. I want to know that I have to do something about _DEBUG in project properties of VS-2008. don't I?

Upvotes: 0

Views: 2068

Answers (2)

TBD
TBD

Reputation: 529

I've had problems with the _DEBUG Macro, what I found very usefull is the IsDebuggerPresent function which returns a boolean:

If the current process is running in the context of a debugger, the return value is nonzero.

If the current process is not running in the context of a debugger, the return value is zero.

Upvotes: 0

nlorch
nlorch

Reputation: 46

_DEBUG is a preprocessor macro. If you right click on properties and go to c/c++, preprocessor is one of the options.

Preprocessor definitions are different for release and debug. If you add SNK_STH to the release preprocessor macros you will see your printf.

If you want to see the code in both debug and release, consider pulling it out of the ifdef.

Upvotes: 1

Related Questions