警告C4800:'int':强制值为bool'true'或'false'(性能警告) [英] Warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

查看:410
本文介绍了警告C4800:'int':强制值为bool'true'或'false'(性能警告)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有这个问题:

bool CBase::isNumber()
{
return (id & MID_NUMBER);
}

bool CBase::isVar()
{
return (id & MID_VARIABLE);
}

bool CBase::isSymbol()
{
return (id & MID_SYMBOL);
}


推荐答案

FYI:隐藏按设计的警告。

FYI: Casts won't hide the warning by design.

return (id & MID_NUMBER) != 0;

应该清楚地说明我想检查这个值是否为零,让编译器快乐

should clearly state "I want to check whether this value is zero or not" and let the compiler be happy

这篇关于警告C4800:'int':强制值为bool'true'或'false'(性能警告)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆