[metadata]
id = "PRE02-C"
type = "recommendation"
category = "PRE"
number = 2
title = "Macro replacement lists should be parenthesized"
description = """
Macro replacement lists should be parenthesized to protect any lower-precedence
operators from the surrounding expression. See alsoPRE00-C. Prefer inline or
static functions to function-like macrosandPRE01-C. Use parentheses within
macros around parameter names. ThisCUBE()macro definition is noncompliant
because it fails to parenthesize the replacement list: #define CUBE(X) (X) * (X)
* (X) int i = 3; int a = 81 / CUBE(i);
"""
severity = "Medium"
likelihood = "Probable"
priority = "P12"
level = "L1"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 19, 2025"
[rules.cert_c.PRE02-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/PRE02-C.+Macro+replacement+lists+should+be+parenthesized"