Jan 6, 2015

[C++] naming convention

What are the rules about using an underscore in a C++ identifier?


  • Reserved in any scope, including for use as implementation macros: 
    • identifiers beginning with an underscore and an uppercase letter 
    • identifiers containing adjacent underscores (or "double underscore") 
  • Reserved in the global namespaces: 
    • identifiers beginning with an underscore 
  • Also, everything in the std namespace is reserved. (You are allowed to add template specializations, though.) From the 2003 C

17.4.3.2.1 
Global names [lib.global.names] Certain sets of names and function signatures are always reserved to the implementation: 
  • Each name that contains a double underscore (_ _) or 
  • begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use. 
  • Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.165 165) 
  • Such names are also reserved in namespace ::std (17.4.3.1).

Refer to the stackoverflow link for detail info(for C99 standard as well)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.