Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14.4 and the explanation is not enough to understand why
#1
MISRA C 2012 guideline says:
Strong typing requires the controlling expression of an if statement or iteration-statement to have
essentially Boolean type.

For example:
typedef unsigned short tudtKalEvents;
#define udtSTOP_EVENT (tudtKalEvents)0x0001;
Code:
if(udtEvents & (tudtKalEvents) udtSTOP_EVENT)
  {
        vidStop();
  }
I think the code is ok, I use the & statement as the conditional expression. As we know, the value is not equal to zero, the condition shall be judged to be true,
why We must use the boolean type?
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)