c++ - Unusual use of a Boolean expression -


this part of code base
code:

bool succ = true; //below place warning there  succ &= draw( e0.x, e0.y, e0.z, (e0.x + dir.x), (e0.y + dir.y), (e0.z + dir.z)); //------ //------ bool draw( float x, float y, float z, float p, float q, float r)   {     bool ret;     ret = fun(x,y,z,p,q,r);     return ret; } 

warning :

warning 514: unusual use of boolean expression info 1786: implicit conversion boolean (assignment) (int bool) 

i don't want increase line of code ,so doing logic in 1 line ...can me in resolving issue ...

you have &= there, these basic types equivalent to

bool succ = ...; succ = succ & draw(...); 

however bitwise & operator takes integer values, succ needs cast int in order compare using bitwise &. when use booleans should instead use

bool succ = ...; succ = draw(...) && succ; 

(as pointed out have change order here since && 1 of few places c++ lazily evaluating)

notice there no &&= operator.

edit: result of draw(...) needs cast int too...


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -