Re: Macro challenge with variable arguments
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