Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

I have this problem in my code:

bool CBase::isNumber() { return (id & MID_NUMBER); }  bool CBase::isVar() { return (id & MID_VARIABLE); }  bool CBase::isSymbol() { return (id & MID_SYMBOL); } 
like image 622
user3157184 Avatar asked Jan 04 '14 10:01

user3157184


1 Answers

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

Something like

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

like image 159
Marco A. Avatar answered Sep 17 '22 13:09

Marco A.