• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSLog() replacement for debugger output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSLog() replacement for debugger output (From: Don Arnel <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Mohsan Khan <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Mohsan Khan <email@hidden>)
 >Re: NSLog() replacement for debugger output (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: NSLog() replacement for debugger output
  • Next by Date: Re: NSLog() replacement for debugger output
  • Previous by thread: Re: NSLog() replacement for debugger output
  • Next by thread: Re: NSLog() replacement for debugger output
  • Index(es):
    • Date
    • Thread