1.项目中用宏的时候,遇到如下警告 Operator ‘?:‘ has lower precedence than ‘*‘; ‘*‘ will be evaluated first 2.错误原因 *操作符的优先级比 ?符号优先级低,会先*运算,结果也许就并不是自己
1.项目中用宏的时候,遇到如下警告
Operator ‘?:‘ has lower precedence than ‘*‘; ‘*‘ will be evaluated first
2.错误原因
*操作符的优先级比 ?符号优先级低,会先*运算,结果也许就并不是自己需要的
类似此错误一般都与优先级有关
3.解决方案(示例)
#define app_rate (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)? screen_width/768 : screen_width/375
self.lv1.sd_layout .rightSpaceToView(self.bg_image,app_rate*205) .topSpaceToView(self.bg_image, app_rate*203) .heightIs(82*app_rate) .widthIs(160*app_rate);
app_rate写在*前面是可以的,或者给宏定义加个括号
#define app_rate ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)? screen_width/768 : screen_width/375)