Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
V2623. MISRA. Macro identifiers should …
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Micro-Optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
toggle menu Contents

V2623. MISRA. Macro identifiers should be distinct.

Sep 22 2023

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:

  • C90: 31 first characters
  • C99: 63 first characters

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:

  • MISRA-C-5.4