MISRA C:2012 Rule 2.5

A project should not contain unused macro declarations

Description

This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Default Analysis.

Rule Definition

A project should not contain unused macro declarations.

Rationale

If a macro is declared but not used, a reviewer does not know if the macro is redundant or if it is unused by mistake.

Additional Message in Report

A project should not contain unused macro declarations: macro macro_name is not used.

Troubleshooting

If you expect a rule violation but do not see it, refer to the documentation of Polyspace Code Prover™ or Polyspace Code Prover Server™.

Examples

expand all

void use_macro (void)
{
    #define SIZE 4
    #define DATA 3

    use_int16(SIZE);
}

In this example, the macro DATA is never used in the use_macro function.

Check Information

Group: Unused Code
Category: Advisory
AGC Category: Readability
Introduced in R2014b