GeneralPurpose-SemicolonAtEndOfMacroΒΆ

Macro replacement must not end with semicolon

Required inputs: IR

Do not end macro definitions with a semicolon. Use of a semicolon will restrict usage of the macro in certain contexts, possibly leading to syntax errors.
Bad code (use in a sub-expression):
#define NEXT(x) ++(x);
int x = 0;
while (1) {
    if (NEXT(x) >= 10) { // ERROR: expands to `if ((x)++; >= 10)`
        break;
    }
}
Bad code (use as control flow branch):
#define NEXT(x) ++(x);
int x = 0;
while (1) {
    if (x < 10)
        NEXT(x); // ERROR: expands to `(x)++;;`, terminating the if-statement
    else
        break;
}
Good code:
#define NEXT(x) (++(x))

Possible Messages

Key

Text

Severity

Disabled

semicolon_at_end_of_macro

Macro replacement must not end with semicolon.

None

False

Options