Re: Macro challenge with variable arguments

2012-11-01 Thread Scott Ribe
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_A

Re: Macro challenge with variable arguments

2012-11-01 Thread Graham Cox
Ah, thanks guys! That works great :) --Graham On 02/11/2012, at 1:46 PM, Gwynne Raskind wrote: > #if LOGGING > #define GCLOGOC(format, ...) GCLogObjCMethod(self, _cmd, __LINE__, > NSStringFromClass([self class]), format, ## __VA_ARGS__) > #else > #define GCLOGOC(format, ...) > #endif > > --

Re: Macro challenge with variable arguments

2012-11-01 Thread Gwynne Raskind
On Nov 1, 2012, at 10:15 PM, Graham Cox wrote: > Hi all, I'm having trouble figuring this out. > > I have a logging function thus: > > voidGCLogObjCMethod( id obj, SEL selector, NSUInteger lineNumber, > NSString* tag, NSString* format, ... ); > > I'd like to be able to wrap this usi

Re: Macro challenge with variable arguments

2012-11-01 Thread Greg Parker
On Nov 1, 2012, at 7:15 PM, Graham Cox wrote: > Hi all, I'm having trouble figuring this out. > > I have a logging function thus: > > voidGCLogObjCMethod( id obj, SEL selector, NSUInteger lineNumber, > NSString* tag, NSString* format, ... ); > > I'd like to be able to wrap this usi

Macro challenge with variable arguments

2012-11-01 Thread Graham Cox
Hi all, I'm having trouble figuring this out. I have a logging function thus: voidGCLogObjCMethod( id obj, SEL selector, NSUInteger lineNumber, NSString* tag, NSString* format, ... ); I'd like to be able to wrap this using a macro that automatically supplies the object, selector, l