What does it mean when a member variable or function are prefixed with underscore? 
Author Message
 What does it mean when a member variable or function are prefixed with underscore?

What does it mean when a variable or function are prefixed with
underscore e.g. _InternalQueryInterface, is it because this function is
macro generated, and if so, is this the only reason for using underscore or
are there other situations?


Thu, 25 Aug 2005 04:03:12 GMT  
 What does it mean when a member variable or function are prefixed with underscore?
Hi Nobody,

I just recently read somewhere that the "official" meaning of _ is:

"...identifiers containing a double underscore (__) or beginning with an
underscore and an uppercase letter are reserved for use by C++
implementations and standard libraries and shall not be used otherwise; no
diagnostic is required."

I suppose for ATL, this means that they wanted to make sure it doesn't
collide with anything you would want to define, and because it works as a
stub for CComObjectRootBase::InternalQueryInterface.

This is all speculation, though.

Kim


Quote:
> What does it mean when a variable or function are prefixed with
> underscore e.g. _InternalQueryInterface, is it because this function is
> macro generated, and if so, is this the only reason for using underscore
or
> are there other situations?



Thu, 25 Aug 2005 04:14:39 GMT  
 What does it mean when a member variable or function are prefixed with underscore?
It just means its a hidden interface.
Open it with VB and you'll see it will only show it if you say, show hidden
interfaces.

For example if you have an interface that has to stream some info to another
one, and you dont really want to bother the user with it, just make it
_ImAhiddenInterface


Quote:
> What does it mean when a variable or function are prefixed with
> underscore e.g. _InternalQueryInterface, is it because this function is
> macro generated, and if so, is this the only reason for using underscore
or
> are there other situations?



Thu, 25 Aug 2005 04:25:47 GMT  
 What does it mean when a member variable or function are prefixed with underscore?
Hi Lucky,

Quote:
> It just means its a hidden interface.

The OP asked about the method _InternalQueryInterface, which is most
definitely NOT an interface. Your facts hold true, just not in this
context... :)

Kim


Quote:
> It just means its a hidden interface.
> Open it with VB and you'll see it will only show it if you say, show
hidden
> interfaces.

> For example if you have an interface that has to stream some info to
another
> one, and you dont really want to bother the user with it, just make it
> _ImAhiddenInterface



> > What does it mean when a variable or function are prefixed with
> > underscore e.g. _InternalQueryInterface, is it because this function is
> > macro generated, and if so, is this the only reason for using underscore
> or
> > are there other situations?



Thu, 25 Aug 2005 04:39:37 GMT  
 What does it mean when a member variable or function are prefixed with underscore?

--------------------

Quote:

>Subject: Re: What does it mean when a member variable or function are

prefixed with underscore?

Quote:
>Date: Sat, 8 Mar 2003 21:39:37 +0100
>Hi Lucky,

>> It just means its a hidden interface.

>The OP asked about the method _InternalQueryInterface, which is most
>definitely NOT an interface. Your facts hold true, just not in this
>context... :)

>Kim



>> It just means its a hidden interface.
>> Open it with VB and you'll see it will only show it if you say, show
>hidden
>> interfaces.

>> For example if you have an interface that has to stream some info to
>another
>> one, and you dont really want to bother the user with it, just make it
>> _ImAhiddenInterface



>> > What does it mean when a variable or function are prefixed with
>> > underscore e.g. _InternalQueryInterface, is it because this function is
>> > macro generated, and if so, is this the only reason for using
underscore
>> or
>> > are there other situations?

Kim basically had the answer correct, we use the _ to avoid naming
collisions with custom code. It is also the recommended way to add
non-standard extensions to C++.

--
Pranish Kumar

Microsoft Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm



Tue, 20 Sep 2005 03:38:18 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. static function access member variable and member function

2. member function and member variable

3. member function and member variable

4. member function and member variable

5. Private member prefix

6. viewing member functions of an object in the debug variables window

7. C2086 error: static local variables in member functions

8. class view dosen't shows member variable's and functions defined with macros

9. Macro to create Get/Set functions from a member variable

10. pointer to member function/variable info?

11. forcing __cdecl convention on member functions without variable arguments

12. static variable defined in a member function

 

 
Powered by phpBB® Forum Software