Operator '?:' has lower precedence than '*'; '*' will be evaluated first(代码片

Posted wycstudy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Operator '?:' has lower precedence than '*'; '*' will be evaluated first(代码片相关的知识,希望对你有一定的参考价值。

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(代码片的主要内容,如果未能解决你的问题,请参考以下文章

AttributeError: 'dict' object has no attribute 'iteritems'

重载操作符 'operator'

如何声明名称为'operator'的变量? [复制]

如何完全绕过`错误:不匹配'operator =='`?

'Tensorboard.util' has no attribute 'Retrier'

萤石-module 'serial' has no attribute 'Serial'