nath
nath

Reputation: 2848

Xcode #ifdef DEBUG is not working properly

I have add following line to the code.

#ifdef DEBUG
        //DEBUG only code
#endif

And I have go to the project->info tab in the xcode and set 'command-line builds use' to debug and run the code the code snippet inside the 'if' executed. The problem is when i set the command-line build' use to release and run the code. The code snippet inside the if condition still runs. I have set the preprocessor DEBUG macros to 'DEBUG=1'without quotes. How to solve this.

Upvotes: 2

Views: 2629

Answers (1)

Kevin Grant
Kevin Grant

Reputation: 5431

The #ifdef syntax means "is defined", without regard to value; in other words, it is defined if it has any value at all (0 or 1).

You probably want the #if syntax instead. This requires that the value actually be set to 1.

Upvotes: 9

Related Questions