GeneralPurpose-BalancedParenthesisInDefines¶
Parenthesis in Macro Definitions should be balanced
Required inputs: IR
(), {} and
[] inside macro replacements are balanced, i.e., there is a corresponding
closing one to each opening one.
Bad code:
void fail(const char *, const char *, int); #define ASSERT(x) ((x) ? (void)0 : fail(#x, __FILE__, __LINE__) // ERROR: Parentheses are unbalanced in macro replacement, missing closing ")".
Good code:
void fail(const char *, const char *, int); #define ASSERT(x) ((x) ? (void)0 : fail(#x, __FILE__, __LINE__)) // OK: Parentheses are balanced in macro replacement.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
extra_at_pos |
Parentheses are unbalanced in macro replacement at position {}, extra “{}”. |
None |
False |
unbalanced_at_end |
Parentheses are unbalanced in macro replacement, missing closing “{}”. |
None |
False |
unbalanced_at_pos |
Parentheses are unbalanced in macro replacement at position {}, expected “{}”. |
None |
False |
Options
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.