【发布时间】:2017-01-17 13:28:18
【问题描述】:
我有一个相当简单的宏,我想用它来记录消息。宏:
#define LogDebug(tag, fmt, ...) [MyLogger logDebug:[NSString stringWithFormat:fmt, ##__VA_ARGS__] \
function:NSStringFromSelector(_cmd) file:@__FILE__ line:__LINE__ tag:tag];
我称之为:
LogDebug(@"tag", @"message");
问题:在@"tag" 的开头我得到Expected ']',其中Xcode 指向宏调用中的@ 符号(不是定义)。
重要提示:如果我删除 tag 变量,一切正常:
#define LogDebug(fmt, ...) [MyLogger logDebug:[NSString stringWithFormat:fmt, ##__VA_ARGS__] \
function:NSStringFromSelector(_cmd) file:@__FILE__ line:__LINE__ tag:@"tag"];
和
LogDebug(@"message");
有什么想法吗?
【问题讨论】:
标签: ios objective-c macros