MISRA C:2012 Dir 4.5
Identifiers in the same name space with overlapping visibility should be typographically unambiguous
Description
Directive Definition
Identifiers in the same name space with overlapping visibility should be typographically unambiguous.
Rationale
What “unambiguous” means depends on the alphabet and language in which source code is written. When you use identifiers that are typographically close, you can confuse between them.
For the Latin alphabet as used in English words, at a minimum, the identifiers should not differ by:
The interchange of a lowercase letter with its uppercase equivalent.
The presence or absence of the underscore character.
The interchange of the letter
O
and the digit0
.The interchange of the letter
I
and the digit1
.The interchange of the letter
I
and the letterl
.The interchange of the letter
S
and the digit5
.The interchange of the letter
Z
and the digit2
.The interchange of the letter
n
and the letterh
.The interchange of the letter
B
and the digit8
.The interchange of the letters
rn
and the letterm
.
Polyspace Implementation
The checker flags identifiers in the same scope that differ from each other only
in the above characters. Polyspace® ignores identifiers that are defined in macros starting with
do
, for
, switch
, and
while
.
If two identifiers are in different scope, their uses are not ambiguous. Polyspace does not report violations of this rule for identifiers that are in different scopes.
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: Code design |
Category: Advisory |
AGC Category: Readability |
Version History
Introduced in R2015b