tugce
tugce

Reputation: 661

xcode preprocessor macros LLVM 4.2

I am trying to set DEBUG_MODE macro for DLOG to work only debug mode but it is not working...

What I tried so far: http://developer.sinnerschrader-mobile.com/llvm-preprocessor-macros-xcode/275/

and naming one more flag as DEBUG_MODE, playing combinations with or without $(inherited) value.

I am all confused, what is green highlighted part stands for? and why is some parts seen empty but when clicked values are seen in it?

How should I configure my macros so that I can really access them for:

#ifdef DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...) do { } while (0)
#endif

enter image description here

EDIT:

This is become really wicked! I have set all values to DEBUG=0 in release mode. And changed

#if DEBUG
#   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define DLog(...) do { } while (0)
#endif

still seeing all logs in release...

enter image description here

Upvotes: 1

Views: 3050

Answers (1)

trojanfoe
trojanfoe

Reputation: 122381

Your Preprocessor macro settings (Debug being DEBUG=1 and Release being DEBUG=0) will cause the first definition of the DLog() macro to be used given you have used #ifdef (if defined) to provide different implementations. This is because the macro will be defined if you define it at all, regardless of what you define it to.

What you need to do is, either:

  • Remove DEBUG=0 from your Release profile.
  • Use #if DEBUG instead of #ifdef DEBUG.

Upvotes: 1

Related Questions