码迷,mamicode.com
首页 > 其他好文 > 详细

Operator '?:' has lower precedence than '*'; '*' will be evaluated first

时间:2018-10-09 10:20:26      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:out   top   rate   nbsp   pad   宏定义   his   highlight   eid   

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)

Operator '?:' has lower precedence than '*'; '*' will be evaluated first

标签:out   top   rate   nbsp   pad   宏定义   his   highlight   eid   

原文地址:https://www.cnblogs.com/wycstudy/p/9758645.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!