Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

leading underscores..



On Sat, 02 Dec 2006 08:52:15 -0500
Stephen Adler <adler at stephenadler.com> wrote:

> This is a programing question, so I hope you guys don't mind my posting 
> to this mailing list.
> 
> I've run across an issue about using underscores in variable names. I've 
> been writing software
> under linux for the past 15 years and I've gotten into the habit of 
> using underscores in my
> variables names for priviate variables in a class. I tried to compile my 
> code on Solaris
> 10 x86 using the gnu compiler and it threw errors because the compiler 
> didn't like the
> leading underscore. Does anyone have any comments on this? If a leading 
> underscore
> is not used to private variable and functions in classes, what the 
> coding standard to indicate
> the variable belongs to the class your coding?
The handling of variable names is defined by the appropriate
programming standard. The C language has 2 standards, 1989 and 1998. 
The C 1989 standard allows a leading underscore for a variable name
(eg. identifier).  By default, this is also allowed in C++.  I can't
comment on other languages. 
Ref: ANS X3-159-1989 Section 3.1.2.40:
"An identifier is a sequence of nondigit characters (including the
underscore _ and the lowercase and uppercase letters) and digits. The
first character shall be a nondigit character".
My copy of the 1998 standard is in a box. 



-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org