2.4 Identifiers

2.4.1 Ensure that each identifier is distinct from any other visible identifier

Similarity of identifiers impairs readability, can cause confusion and may lead to mistakes. Names should not differ only in case (foo/Foo) or in use of underscores (foobar/foo_bar). Additionally, certain combinations of characters look very similar:

  O(o) 0
  I(i) l(L) 1
  S(s) 5
  Z(z) 2
  n(N) h
  B(b) 8

rn(RN) m Identifiers that only differ in the above characters should also be avoided. This rule applies to pairs of identifiers that can be used in the same scope, i.e. one of them is visible with respect to the other. Note: This rule does not require that an identifier cannot be reused. See Rule <hicpp ref=”basic.scope.no-hide”/>.

// t1.cc

int32_t he1lo;    // @@- Non-Compliant -@@
int32_t hel1o;    // @@- Non-Compliant -@@
void FOO ()
int32_t world;  // @@+ Compliant: 'wor1d' is not visible +@@
void BAR ()
int32_t wor1d;  // @@+ Compliant: 'world' is not visible +@@
// t2.cc
int32_t F00;      // @@- Non-Compliant: 'FOO' is visible -@@


  • HIC++ v3.3 – 8.3.4
  • MISRA C++:2008 – 2-10-1
  • Meyers Notes – Reference Binding Rules

Click here for references