lundi 30 novembre 2020

How do I fix the Werror=parantheses (suggest parantheses around assignment) error?

I have a line of code which does both assignment and condition. I could split it into two lines but I'm just curious about the error message thrown.

  if ( parameters->__size = m_Elements.size() ) 

Got this error: suggest parentheses around assignment used as truth value [-Werror=parentheses]

I tried:

   if ( (parameters->__size) = (m_Elements.size()) )

The error doesn't go away. But I feel I have done what I was prompted to do and added parentheses around the assignment. Why doesn't the error go away? What am I missing?

Aucun commentaire:

Enregistrer un commentaire