Reputation: 23
I created a va_list version of variadic method:
+(void)myFunc:(NSString *)message args:(va_list)args;
and created macro TESTLOG
that call to above function
#define TESTLOG(x,...) [MyExample myFunc:(x), ##__VA_ARGS__]
the problem is that when i am try calling to TESTLOG
macro, I get an error:
TESTLOG("test");
TESTLOG(@"test",@"test1");
Expected expression
How I can solve this issue? I tried to replace args:(va_list)args
with ...
it is working, but in my case I need to use the va_list and macro.
I think that my issue is with the definition in the macro.
Upvotes: 1
Views: 168
Reputation: 318814
You can't use the __VA_ARGS__
macro with a va_list
argument. Your Objective-C method needs to be defined as:
+ (void)myFunc:(NSString *)message, ... ;
Then your macro can be:
#define TESTLOG(x,...) [MyExample myFunc:(x), __VA_ARGS__]
Upvotes: 1