Re: Which has higher precedence & or ==

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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: syntax query: ($var++ && next) if /match/
    ... non-alphanumeric characters to it. ... natural language text I would respectfully disagree and I suspect you ... that I'd rather put in some unnecessary parentheses from time to ... meaning only to someone who knows the relative precedence of all ...
    (comp.lang.perl.misc)
  • Re: Article about Herb Schildt accepted at comp.risks
    ... entitled to change the order of evaluation if the precedence is ... implementation is entitled to use any order of evaluation in likes. ... better way to say it is that parentheses themselves have very high ... that most American programmers simply do not code much. ...
    (comp.lang.c)
  • Re: Article about Herb Schildt accepted at comp.risks
    ... Do you mean there is no such page, or do you mean that Microsoft's compiler allows the control of evaluation order via parentheses? ... 'Parentheses are operators that increase the precedence of the ... Precedence is about which operands are associated with which operators, whereas order of evaluation is all about the order in which things are evaluated. ...
    (comp.lang.c)
  • Re: What is the output of the following code?
    ... In an expression with nested parentheses, ... highest precedence. ... Your rule is not enough to define the semantics of a macro processor, ...
    (comp.lang.c)