Re: Which has higher precedence & or ==

Tech-Archive recommends: Speed Up your PC by fixing your registry



Unfortunately I do have to worry about it. That's what Petzold wrote. And I'm trying to fix it.

--
George Hester
_________________________________
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx> wrote in message news:uuoiDGxQFHA.1396@xxxxxxxxxxxxxxxxxxxxxxx
> George Hester wrote:
> > I have this example in a window procedure:
> > fBlocking is BOOL and wParam is an argument of the window procedure.
> >
> > switch (iMsg){
> > //
> > case WM_CHAR:
> > if (fBlocking & wParam == '\x1B'){
> > //
> > }
> > retrurn 0;
> > //
> > }
> >
> > Like this we get a warning:
> >
> > warning C4554: '&' : check operator precedence for possible error;
> > use parentheses to clarify precedence
> >
> > But I don't know what the precedence was expected here to put the
> > parens in correctly.
> > Any ideas?
>
> Add parentheses to make it mean what you wanted it to mean - don't worry too
> much about what it means without parentheses.
>
> There's no table of operator precedence in the C++ standard, but the 17
> levels of precedence can be deduced from the grammar. To make a long story
> short, == has higher precedence than &, so your expression almost certainly
> doesn't mean what you wanted without parentheses.
>
> -cd
>
>
>
>

.



Relevant Pages

  • Re: operator precedence in Fortran 2008 draft
    ... to take operands of type BITS. ... to overload the relational operators as well, ... the operator precedence chosen by standard ... forces the use of parentheses in the common cases. ...
    (comp.lang.fortran)
  • Re: question about pointer
    ... parentheses will somehow force complete evaluation of the increment ... Overriding precedence can sometimes have the effect of ... same - the parens are redundant. ...
    (comp.lang.c)
  • Re: VHDL Operator associativity (Quartus II parser bug?)
    ... states that or and and have the same precedence. ... Yes, but LRM 7.1 gives the BNF for expressions, ... in an expression without parentheses, ... DOULOS - Developing Design Know-how ...
    (comp.lang.vhdl)
  • Re: Reason for operator precedence
    ... Having multiple levels of precedence obviously adds complexity, ... I meant to make it work without needing parentheses, ... convention of your choice. ... Polish or Reverse Polish notation. ...
    (sci.math)
  • Re: While query
    ... > Sorry, I jumped the gun. ... I didn't notice the parentheses around $x. ... Don't worry about it. ... As Abigail also noted, I should have explained why & ...
    (comp.lang.perl.misc)