...
DCL02-C implicitly assumes 'Global Scope' which can be confused with 'Scope within the same file'. Though it may not generate any errors, but there may be a possible violation of the rule as in the example below. Note the example below does not violate DCL32-C. Guarantee that mutually visible identifiers are unique
In file foo.h
| Code Block | ||
|---|---|---|
| ||
In file foo.h :: int id_O; // (captial letter O) |
In
...
file
...
bar.h
| Code Block | ||
|---|---|---|
| ||
:: int id_0; // (numeric letter zero) |
If a file foobar.h c includes both foo.h and bar.h and another file foobar.c that includes foobar.h uses both id0 and idO, it is a violation of DCL02-C, then both id_0 and id_0 come in the same scope, violating this rule.
Compliant Solution (Source Character Set)
In a compliant solution, use of visully similar identifiers should be avoided in the same project scope.
In file foo.h:
| Code Block | ||
|---|---|---|
| ||
In file foo.h :: int id_a; |
In
...
file
...
bar.h
| Code Block | ||
|---|---|---|
| ||
:: int id_b; |
Risk Assessment
Failing to use visually distinct identifiers can result in referencing the wrong object or function, causing unintended program behavior.
...