Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 19.4 do-while(0) for single statements
#2
I believe what they are trying to do is to force your macro statement to require a ";" at the end, making it look like the termination of a C expression-statement. There are only a couple of statements (see C90 section 6.6) that require termination with a ";", the expression-statement, the do iteration-statement and the jump-statement. Since without the ";" the expression-statement is simply an expression, which is allowed by Rule 19.4, I think this makes good sense.

Note that I cannot find this rule in the MISRA C:2012 version, so it may be that the MISRA committee now agrees with your view.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)