Use of double underscores in identifiers in libc++

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of double underscores in identifiers in libc++

Alex Rosenberg
Maybe I'm paranoid, but I'm predicting identifier clashes with  
intrinsics due to the use of double underscores.

[lib.global.names] touches on this, but my expectation from  
established convention is that the library should use identifiers that  
start with a single underscore and leave the double underscore  
identifiers for use in the compiler itself (and platform-specific  
compiler headers like altivec.h).

+------------------------------------------------------------+
| Alexander M. Rosenberg        <mailto:[hidden email]> |
| Nobody cares what I say, so no disclaimer appears here.    |

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Use of double underscores in identifiers in libc++

Howard Hinnant
On May 13, 2010, at 2:29 AM, Alex Rosenberg wrote:

> Maybe I'm paranoid, but I'm predicting identifier clashes with  
> intrinsics due to the use of double underscores.
>
> [lib.global.names] touches on this, but my expectation from  
> established convention is that the library should use identifiers that  
> start with a single underscore and leave the double underscore  
> identifiers for use in the compiler itself (and platform-specific  
> compiler headers like altivec.h).

It is true that the double underscore names may clash with compiler intrinsics.  This is just one of many reasons why it is very difficult to make a 100% portable std C++ library.  The std lib exists so that its clients can write more portable code.  That doesn't mean the std lib itself is necessarily portable.

"The implementation" mentioned in [global.names] refers to the compiler/std-lib combination.  From our client's point of view it really doesn't matter if __foo is reserved for the compiler or for the std lib.

libc++ always uses one of:

1.  __[a-z]
2.  _[A-Z]
3.  An identifier that is explicitly reserved by the (draft) standard.

This convention is not unusual with respect to other std lib implementations.

-Howard


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev