Prefixing names with an underscore 
Author Message
 Prefixing names with an underscore

A while ago I asked about using identifiers that begin with an underscore.
I was advised (I think) that identifiers like this are used internally by a
compiler, and hence should be avoided to avoid possible complications.  But
viewing professional source code e.g. Microsoft DirectX, I see that
underscores are used as the first character of identifiers.  For example
(from ddraw.h):

typedef struct _DDSCAPS
{
    DWORD dwCaps;  // capabilities of surface wanted

Quote:
} DDSCAPS;

Is this bad practice?  Or does it not matter in this example?

Cheers.



Fri, 28 Mar 2003 03:00:00 GMT  
 Prefixing names with an underscore

Quote:

> A while ago I asked about using identifiers that begin with an underscore.
> I was advised (I think) that identifiers like this are used internally by a
> compiler, and hence should be avoided to avoid possible complications.  But
> viewing professional source code e.g. Microsoft DirectX, I see that
> underscores are used as the first character of identifiers.

Microsoft thinks that it is the compiler vendor, so it feels
justified in writing _ at the beginning of identifiers.  And a
lot of Microsoft source code isn't what I'd call "professional"
anyway.
--
"You call this a *C* question? What the hell are you smoking?" --Kaz


Fri, 28 Mar 2003 03:00:00 GMT  
 Prefixing names with an underscore
Andy Maddison a crit dans le message

complications.  But

Quote:
>viewing professional source code e.g. Microsoft DirectX, I see that

Ha ha ha hah ah ah ah ah h ....

--
-hs-    Tabs out, spaces in.
CLC-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
ISO-C Library: http://www.dinkum.com/htm_cl
FAQ de FCLC : http://www.isty-info.uvsq.fr/~rumeau/fclc
"Abracadabrantesque !" -- Jacques Chirac



Sat, 29 Mar 2003 06:08:40 GMT  
 Prefixing names with an underscore

Quote:

> A while ago I asked about using identifiers that begin with an underscore.
> I was advised (I think) that identifiers like this are used internally by a
> compiler, and hence should be avoided to avoid possible complications.  But
> viewing professional source code e.g. Microsoft DirectX,

Professional source code from Microsoft? When did that happen?

--

K&R: Exercise 8 and counting (started yesterday).
Comp-unix-programmer: FAQ
URL: http://www.erlenstar.demon.co.uk/unix/faq_toc.html
URL: http://www.whitefang.com/unix/faq_toc.html

comp.lang.c FAQ:
 <http://www.eskimo.com/~scs/C-faq/top.html>.



Sat, 29 Mar 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. When is it ok to prefix names with an underscore

2. Usage of underscores as a prefix

3. Underscore Prefixes

4. Underscore Prefixes

5. using prefix letters for variable naming coding style.

6. name of library specified in importlib() not apearing as nemaspace prefix in generated header

7. Prefix of variable names

8. CLS, naming, underscore, and readonly properties

9. Leading underscore in function name

10. SQLTables fails when database name include underscore.

11. Lib file for dll contains underscore in front of names

12. What does it mean when a member variable or function are prefixed with underscore?

 

 
Powered by phpBB® Forum Software