www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

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

↑ ↓ ← 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
↑ ↓ "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
↑ ↓ 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
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
↑ ↓ → 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
→ "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