www.digitalmars.com         C & C++   DMDScript  

c++ - "_handle" or "__handle" as class member name

reply sevki <mesti_mudam yahoo.com> writes:
when i try to use "_handle" or "__handle" as a class member name with(out) -NF
option, the compiler gets crazy.
Nov 21 2006
parent reply "Matthew" <matthew hat.stlsoft.dot.org> writes:
The language standard reserves name beginning with _ and any name with __ in
it.

My convention for members is m_???, e.g. m_name, m_address. It has served me
well. :-)

"sevki" <mesti_mudam yahoo.com> wrote in message
news:ejvbni$27q1$1 digitaldaemon.com...
 when i try to use "_handle" or "__handle" as a class member name

 option, the compiler gets crazy.

Nov 21 2006
parent reply sevki <mesti_mudam yahoo.com> writes:
it only happens for "_handle" and "__handle", not -for instance- for _myVar or
__myVar2

 The language standard reserves name beginning with _ and any name with __ in
it.

r u sure about this? it sounds weird. i recall seeing many variable names starting with _ or __ in standard headers.
Nov 21 2006
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
sevki wrote:

 it only happens for "_handle" and "__handle", not -for instance- for
 _myVar or __myVar2
 
 The language standard reserves name beginning with _ and any name with __
 in it.

r u sure about this? it sounds weird. i recall seeing many variable names starting with _ or __ in standard headers.

Well, if they are standard headers, then they should be allowed to use names reserved by the standard, no? -- Lars Ivar Igesund blog at http://larsivi.net DSource & #D: larsivi
Nov 21 2006
parent sevki <mesti_mudam yahoo.com> writes:
 Well, if they are standard headers, then they should be allowed to use names

the compiler doesnt make a distinction whether an included header is vector or myVector, does it? anyway, the web page says __handle is a keyword for 16 bit DOS binaries and it is not treated as a keyword for other executable types if -NF switch is used. the behavior is not so, as i said in my 1st message.
Nov 21 2006
prev sibling parent "Matthew" <matthew hat.stlsoft.dot.org> writes:
"sevki" <mesti_mudam yahoo.com> wrote in message
news:ejvnce$2lt7$1 digitaldaemon.com...
 it only happens for "_handle" and "__handle", not -for instance- for

 __myVar2

 The language standard reserves name beginning with _ and any name with


 r u sure about this?

Yes
 it sounds weird. i recall seeing many variable names starting
 with _ or __ in standard headers.

As Lars says, if they're reserved for the use of the implementation, then they can (and might) be used by the implementation. The reason you're getting problems with one symbol and not others is that that symbol will be used and not the others. Walter'll be able to say for sure - or any of us can grep the headers - but my guess is that _handle is a #define. Thus, when the preprocessor has done its work, your member declaration will be quite different from what you might expect. As for a standard nomenclature, you must decide on your own, or borrow one. Mine is to use a m_ prefix for non-static, non-public member variables, and to use a suffix of _ for private "worker-bee" functions. Others use a _ suffix for member variables. Yet others use a m prefix. And so on. One thing's for sure: using a _ prefix is going to be unportable, as your experience demonstrates. HTH Matthew
Nov 21 2006