C++ name with leading underscore character not Compiling
Adye, TJ (Tim)
Mon Apr 16 11:50:00 GMT 2007
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
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 (22.214.171.124)]"
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.)
=========================== 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
More information about the Cygwin