Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I am interested to try it on the platforms:
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si vous n'avez toujours pas reçu de réponse, vérifiez votre dossier
Spam/Junk et cliquez sur le bouton "Not Spam".
De cette façon, vous ne manquerez la réponse de notre équipe.

>
>
>
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.

22 Sep 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