Re: NSLog() replacement for debugger output
Re: NSLog() replacement for debugger output
- Subject: Re: NSLog() replacement for debugger output
- From: Don Arnel <email@hidden>
- Date: Thu, 24 Apr 2008 18:42:45 -0400
Good point! I've only used it with arguments so far. Here is a better
version:
#ifdef __DEBUG_OUT__
#define DBOut(fmt, ...) fprintf(stderr, "%s\n", [[NSString
stringWithFormat:(fmt), ## __VA_ARGS__]
cStringUsingEncoding:NSUTF8StringEncoding])
#define DBCOut(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
#else
#define DBOut(fmt, ...)
#define DBCOut(fmt, ...)
#endif
On Apr 24, 2008, at 6:29 PM, Ken Thomases wrote:
There should be two hash characters ("##") before the __VA_ARGS__.
That's a gcc feature such that, if the macro is used without passing
arguments beyond the format string, then the comma is removed from
the expansion.
-Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden