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);
}
Join Stack Overflow to learn, share knowledge, and build your career.
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);
}
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
Use the !! idiom eg
bool CBase::isNumber()
{
return !!(id & MID_NUMBER);
}
Where's the declaration of id and MID_NUMBER? Are you sure they are not windef-style BOOLs rather than (lowercase) bool's? BOOL's have been in windef for decades typedef'd as an int; they pre-date proper C++ bool's and a lot of developers still use them.
return (id & MID_NUMBER) > 0;
? – πάντα ῥεῖ Jan 4 '14 at 10:22(id & MID_NUMBER) != 0;
is the general way to avoid the warning. – Retired Ninja Jan 4 '14 at 10:24