4

I used a macro version of NSLog from here, http://objdev.com/2014/06/debug-logging

like this,

#ifdef DEBUG
#define DLog(...) NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__])
#endif

It was working fine, until I changed the app run mode from Debug to Release.

Now I get the following error:

Implicit declaration of function 'DLog' is invalid in C99.

How do I solve this?

I read many questions, error:'implicit declaration of function 'nslog' is invalid at C99', ARC warning: Implicit declaration of function 'DLog' is invalid in C99 and Implicit declaration of function - C99, but none of the answers work for me.

P.S. This question isn't related to CocoaLumberjack at all.

Community
  • 1
  • 1
Hemang
  • 26,840
  • 19
  • 119
  • 186

2 Answers2

19

Error tells you that DLog doesn't have any definition in Release Mode. Just change it to this:

#ifdef DEBUG
#define DLog(...) NSLog(@"%s(%p) %@", __PRETTY_FUNCTION__, self, [NSString stringWithFormat:__VA_ARGS__])
#else
#define DLog(...)
#endif

EDIT : If it is a Release mode DLog will do nothing(A Blank Function). And if it is a debug mode DLog will print the log as per your requirements.

Mohamed Elkassas
  • 829
  • 1
  • 13
  • 33
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
0

The macro is only defined when you compile your code e debug mode because of the #ifdef DEBUG directive

Guilherme Torres Castro
  • 15,135
  • 7
  • 59
  • 96