This diagnostic rule is based on the software development guidelines developed by MISRA (Motor Industry Software Reliability Association).
This diagnostic rule is relevant only to C programs. The macro identifier should be distinct from the identifiers of previously defined macros. The macro parameter identifier should be also distinct from the macro identifier itself and from all other parameters.
The minimum requirement for distinction of the macro identifiers and their parameters depends on the version of the C Standard:
In practice, compilers can exceed these limits. However, the diagnostic rule requires that macro identifiers should be distinct within the limits recommended by standard.
The following examples are relevant to C90.
The example of incorrect code with the macro identifier:
// 1234567890123456789012345678901
#define average_winter_air_temperature_monday awt_m
#define average_winter_air_temperature_tuesday awt_t
The first macro identifier is indistinct from the second one, if we take the first 31 characters. Here is the correct code:
// 1234567890123456789012345678901
#define average_winter_air_temp_monday awt_m
#define average_winter_air_temp_tuesday awt_t
The example of incorrect code with indistinct macro identifier and its parameters:
#define average_winter_air_temp(average_winter_air_temp) awt_m
The correct code:
#define average_winter_air_temp(winter_air_temp) awt_m
The example of incorrect code with indistinct identifiers of macro parameters:
#define air_temp(winter_air_temp, winter_air_temp) awt_m
The correct code:
#define air_temp(average_winter_air_temp, winter_air_temp) awt_m
This diagnostic is classified as:
|