V2633. MISRA. Identifiers should be distinct from macro names.
This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.
This rule is relevant only for C.
Macro names must be different from identifier names.
The minimum requirements for their distinction depend on the standard version:
- C90: first 31 characters are significant;
- C99: first 63 characters are significant.
The diagnostic rule requires that names should be distinct within the constraints recommended by the C standard.
The following examples are relevant to C90.
The example of the incorrect code:
// 1234567890123456789012345678901
#define average_winter_air_temperature_Monday awt_m
static int average_winter_air_temperature_tuesday;
Macro names are indistinct from identifier names when comparing the first 31 characters.
The correct code:
// 1234567890123456789012345678901
#define average_winter_air_temp_Monday awt_m
static int average_winter_air_temp_tuesday;