Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Class Bascis Question... Pin
Axter6-May-06 16:43
professionalAxter6-May-06 16:43 
GeneralRe: Class Bascis Question... Pin
Stephen Hewitt6-May-06 18:32
Stephen Hewitt6-May-06 18:32 
GeneralRe: Class Bascis Question... Pin
Maxwell Chen6-May-06 19:16
Maxwell Chen6-May-06 19:16 
GeneralRe: Class Bascis Question... Pin
Phil C6-May-06 20:12
Phil C6-May-06 20:12 
AnswerRe: Class Bascis Question... Pin
Maxwell Chen6-May-06 20:44
Maxwell Chen6-May-06 20:44 
GeneralRe: Class Bascis Question... Pin
Axter7-May-06 1:05
professionalAxter7-May-06 1:05 
GeneralRe: Class Bascis Question... Pin
Maxwell Chen7-May-06 2:02
Maxwell Chen7-May-06 2:02 
GeneralRe: Class Bascis Question... Pin
Axter7-May-06 5:53
professionalAxter7-May-06 5:53 
Maxwell Chen wrote:
Section 17.4.3.1.2 in ISO/IEC 14882:2003

1. 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.


I'm not sure why you posted the standard.
But I'll explain what the standard is stating, incase you think it contridicts my comment.

The first paragraph is stating that the implementation can use names that are prefxied with double underscore or underscore followed by an uppercase letter for ANY use.

Any use includes using them for MACROS.

#define _T(x) L ## x

That means these types of variables will enter ALL namespaces.
So if you have a local variable called _T, it will not compile if using a header with above macro.

The second paragraph is stating that the implementation can put any name that begins with an underscore inside the global namespace.

FILE * _wfdopen(int, const wchar_t *);

The above function is in the MS header files, and it enters the global namespace, but not local namespace.
So you can create a local variable named _wfdopen, and it will not conflict with the global namespace function.

So IAW C++ standard, it's safe to use a local variable with a leading underscore followed by a lowercase letter.
*** HOWEVER *** some implementations like MS use names with lowercase letters for macros, which means they intrude into all namespaces.
#define _tfdopen _wfdopen
#define _tfsopen _wfsopen
#define _tfopen _wfopen


So my general advise, is to avoid using names that begin with an underscore completely.
And if you feel you have to use an underscore, use a trailing underscore instead.
Example:
int MyFoo_; //Instead of _MyFoo


Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus

-- modified at 11:59 Sunday 7th May, 2006
GeneralRe: Class Bascis Question... Pin
Maxwell Chen7-May-06 6:22
Maxwell Chen7-May-06 6:22 
GeneralRe: Class Bascis Question... Pin
Axter7-May-06 1:20
professionalAxter7-May-06 1:20 
QuestionRe: Class Bascis Question... Pin
Maxwell Chen7-May-06 2:08
Maxwell Chen7-May-06 2:08 
AnswerRe: Class Bascis Question... Pin
Axter7-May-06 5:57
professionalAxter7-May-06 5:57 
GeneralRe: Class Bascis Question... Pin
Maxwell Chen7-May-06 6:08
Maxwell Chen7-May-06 6:08 
Questionhow to get ip address of my own system Pin
noumanzaidi6-May-06 1:39
noumanzaidi6-May-06 1:39 
AnswerRe: how to get ip address of my own system Pin
Hamid_RT6-May-06 1:48
Hamid_RT6-May-06 1:48 
AnswerRe: how to get ip address of my own system Pin
Mila0257-May-06 21:19
Mila0257-May-06 21:19 
Questionerror(plz give the solution for this) Pin
Reddyb6-May-06 1:26
Reddyb6-May-06 1:26 
AnswerRe: error(plz give the solution for this) Pin
Hamid_RT6-May-06 1:57
Hamid_RT6-May-06 1:57 
AnswerRe: error(plz give the solution for this) Pin
Cedric Moonen6-May-06 1:58
Cedric Moonen6-May-06 1:58 
AnswerRe: error(plz give the solution for this) Pin
guestcat6-May-06 2:17
guestcat6-May-06 2:17 
AnswerRe: error(plz give the solution for this) Pin
Hamid_RT6-May-06 4:50
Hamid_RT6-May-06 4:50 
Questiondll to source Pin
Try6-May-06 1:20
Try6-May-06 1:20 
AnswerRe: dll to source Pin
Milton Karimbekallil6-May-06 1:42
Milton Karimbekallil6-May-06 1:42 
AnswerRe: dll to source Pin
Chris Losinger6-May-06 16:12
professionalChris Losinger6-May-06 16:12 
QuestionRe: dll to source code Pin
Try8-May-06 19:20
Try8-May-06 19:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.