This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: C++ name with leading underscore character not Compiling


Hi,

Dave Korn wrote on 16 April 2007 12:29:
>
>   Thanks for the correction.  I'm referring to the C 
> standard; I think C++ follows basically the same rules but
> don't have a spec handy to refer to.

The C++ standard is a little different, but the result in this case is
the same:-

"17.4.3.1.2/1

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.
  [such names are also reserved in namespace ::std (17.4.3.1)]"

This means that a single leading underscore is fine in local scope, as
long as it is not followed by an uppercase letter (I am only aware of
conflicts with a single upper-case character (eg. _L), but I think the
standard would also prevent _Local).

So, the case here ("_name" as an argument name) should be fine.

(This could have been an issue for my project, since we adopted the
convention of "leading underscore for member variables" before C++ had
been standardized. Fortunately, we also had adopted the convention of
using keeping the first letter of identifiers lower case.)

Tim.

===========================  cut here  ============================
 Tim Adye      T.J.Adye@rl.ac.uk       http://hepunx.rl.ac.uk/~adye
 BaBar/Atlas Groups, Particle Physics Dept, Rutherford Appleton Lab

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]