MISRA C:2012 Rule 5.2
Identifiers declared in the same scope and name space shall be distinct
Description
Rule Definition
Identifiers declared in the same scope and name space shall be distinct1 .
Rationale
If the two long names are almost identical and differ only in the later part, they can be easily mistaken for each other. The readability of the code is reduced.
Polyspace Implementation
Polyspace® considers two names as distinct if there is a difference between their
first 63 characters. In C90, the difference must occur between the first 31
characters. To use the C90 rules checking, use the value c90
for
the option C
standard version (-c-version)
. You can change the number of
characters compared using the option
-code-behavior-specifications
. See -code-behavior-specifications
.
Additional Message in Report
Identifier XX has same significant characters as identifier YY.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Identifiers |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2014b
See Also
MISRA C:2012 Rule 5.1
| MISRA C:2012 Rule 5.3
| MISRA C:2012 Rule 5.4
| MISRA C:2012 Rule 5.5
| Check MISRA C:2012 (-misra3)
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.