Reputation: 64834
I'm not experienced in C, so I'm not comfortable with this statement in this C / objective-C project.
#define CBLog(...) NSLog(@"%s [%ld]: %@", basename(__FILE__), __LINE__, [NSString stringWithFormat:__VA_ARGS__])
Questions:
the 3 dots (...) are used to indicate CBLog() is a method with parameters ? What do they mean ?
%ld stands for line format ? what's the d in %ld for ?
FILE , LINE and VA_ARGS are default replacement tokens for the C debugger ?
thanks
Upvotes: 3
Views: 285
Reputation:
...
means that any number of arguments can be given.%ld
means signed long
, though it's a bit strange as I've never seen signed line numbers.__FILE__
is the current source file's filename. __LINE__
is the current line number. __VA_ARGS__
are the arguments given to the macro.Upvotes: 2
Reputation: 375474
The ...
means the macro accepts any number of arguments.
%ld
is a string formatter meaning 'long decimal', where decimal really means integer.
__FILE__
expands to the current file name
__LINE__
expands to the current line number
__VA_ARGS__
expands to the arguments passed to the macro.
The debugger has nothing to do with it. All of this is the preprocessor, except %ld
which is string formatting.
Upvotes: 5