Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If an if, while, or for statement is used in a macro, the macro definition should not conclude with a semicolon. (See guideline recommendation PRE11-C. Do not conclude macro definitions with a semicolon.)

...

Braces also help ensure that macros with multiple statements are properly expanded. Such a macro should be wrapped in a do-while loop. (See guideline recommendation PRE10-C. Wrap multi-statement macros in a do-while loop.) However, when the do-while loop is not present, braces can still ensure that the macro expands as intended.

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

EXP19-C

medium

probable

medium

P8

L2

Bibliography

Related Guidelines

Wiki Markup\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.8.4, "Selection statements"

MISRA Rule 14.8

Bibliography

Wiki Markup

\[[MISRA 2004|AA. Bibliography#MISRA 04]\] Rule 14.8
\[[GNU 2010|AA. Bibliography#GNU 10]\] [Coding Standards, Section 5.3, "Clean Use of C Constructs"|http://www.gnu.org/prep/standards/standards.html#Syntactic-Conventions]

...