Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
C6281
Collapse the table of content
Expand the table of content

C6281

Warning 6281 - incorrect order of operations: relational operators have higher precedence than bitwise operators

This warning indicates a possible error in the operator precedence. This might produce incorrect results. You should check the precedence and use parentheses to clarify the intent. Relational operators (<, >, <=, >=, ==, != ) have higher precedence than bitwise operators (& | ^).

The following code generates this warning:

#include <stdlib.h>
#define FORMAT 1
#define TYPE 2

void f(int input)
{
  if (FORMAT & TYPE != input)
  {
    // code...
  }
}

The following code uses parentheses to correct this warning:

#include <stdlib.h>
#define FORMAT 1
#define TYPE 2

void f(int input)
{
  if ((FORMAT & TYPE) != input)
  {
    // code...
  }
}
Show:
© 2015 Microsoft