Hemang
Hemang

Reputation: 27072

Implicit declaration of function 'DLog' is invalid in C99

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.

Upvotes: 4

Views: 8541

Answers (2)

Nirav Gadhiya
Nirav Gadhiya

Reputation: 6342

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.

Upvotes: 19

Guilherme Torres Castro
Guilherme Torres Castro

Reputation: 15350

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

Upvotes: 0

Related Questions