[metadata]
id = "PRE11-C"
type = "recommendation"
category = "PRE"
number = 11
title = "Do not conclude macro definitions with a semicolon"
description = """
Macros are frequently used to make source code more readable. Macro definitions,
regardless of whether they expand to a single or multiple statements, should not
conclude with a semicolon. (SeePRE10-C. Wrap multistatement macros in a do-while
loop.) If required, the semicolon should be included following the macro
expansion. Inadvertently inserting a semicolon at the end of the macro
definition can unexpectedly change the control flow of the program. Another way
to avoid this problem is to prefer inline or static functions over function-like
macros. (See alsoPRE00-C. Prefer inline or static functions to function-like
macros.) In general, the programmer should ensure that there is no semicolon at
the end of a macro definition. The responsibility for having a semicolon where
needed during the use of such a macro should be delegated to the person invoking
the macro.
"""
severity = "Medium"
likelihood = "Probable"
priority = "P8"
level = "L2"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 19, 2025"
[rules.cert_c.PRE11-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/PRE11-C.+Do+not+conclude+macro+definitions+with+a+semicolon"