• 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: Macro challenge with variable arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macro challenge with variable arguments


  • Subject: Re: Macro challenge with variable arguments
  • From: Scott Ribe <email@hidden>
  • Date: Thu, 01 Nov 2012 21:02:20 -0600

What Gwynne said, but with one potential change, *some* versions of GCC require a space before the last comma in order for it to be omitted if there are 0 variable args, as in:

#define GCLOGOC(format, ...) GCLogObjCMethod(self, _cmd, __LINE__, NSStringFromClass([self class]), format , ## __VA_ARGS__)

Of course it's one of those things that if it works in the versions of GCC you're using, great, and if it doesn't, oh boy it might take you a while to figure out that error message.

(Or not, you might conclude it can't be done and give up--and indeed in standard C a macro like this cannot accept 0 varargs, this is a GCC extension. Of course for this one you could let format be the first vararg, but that trick is not always feasible.)


--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice





_______________________________________________

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: 
 >Macro challenge with variable arguments (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Macro challenge with variable arguments
  • Next by Date: Core Data user Info
  • Previous by thread: Re: Macro challenge with variable arguments
  • Next by thread: -[NSManagedObject setValuesForKeysWithDictionary:] and C++ attributes
  • Index(es):
    • Date
    • Thread