这个宏有什么问题? [英] What is wrong with this Macro?
本文介绍了这个宏有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#define mySynthesize(op) @synthesize op = _op;
所以与其打字
@synthesize someVar=_someVar;
@synthesize otherVar=_otherVar;
我能做到
mySynthesize (someVar);
好吧,但它不起作用.我做错了什么?
Well, it doesn't work though. What did I do wrong?
推荐答案
当您在 op
前加上下划线时,预处理器会将其视为不同的标记,因此不会被替换.您需要使用 ##
将下划线连接到前面,以便首先发生替换.
When you prefix the op
with an underscore, the preprocessor treats it as a different token, so it doesn't get replaced. You need to use ##
to concatenate the underscore to the front so that the replacement occurs first.
#define mySynthesize(op) @synthesize op = _ ## op
这篇关于这个宏有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文