2-10-1 No "overlapping visibility" restriction?

Moderators: david ward, misra cpp

Post Reply
Posts: 15
Joined: Wed May 14, 2014 1:02 pm
Company: Axivion GmbH

2-10-1 No "overlapping visibility" restriction?

Post by grunwald » Thu Mar 16, 2017 2:14 pm

C 2012 Directive 4.5: "Identifiers in the same name space with overlapping visibility should be typographically unambiguous"
C++ Rule 2-10-1: "Different identifiers shall be typographically unambiguous."

Does this mean the C++ rule applies even to identifiers in different scopes?

Code: Select all

void f1() { int i; }
void f2() { int I; } // 2-10-1 violation due to only differing in case?
Also, does the C++ rule forbid naming a variables after their class name?

Code: Select all

class MyClass { };
MyClass myClass;  // 2-10-1 violation?

misra cpp
Posts: 157
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: 2-10-1 No "overlapping visibility" restriction?

Post by misra cpp » Mon Jul 10, 2017 10:58 am

Uses of i and I in different scopes are non-compliant as is MyClass myClass

We are considering adopting the C12 directive for the next version
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.2 Lexical conventions (C++)”