enum syntax 
Author Message
 enum syntax

A question about your tastes in programming style: When defining enum data,
do you prefer to write the enum elements in UPPER or lower case?

I.e.:

enum Fred {ONE, TWO, THREE};

or

enum Fred {one, two, three};

Regards.



Thu, 17 Feb 2005 09:24:59 GMT  
 enum syntax


Quote:
> A question about your tastes in programming style: When defining enum data,
> do you prefer to write the enum elements in UPPER or lower case?

> I.e.:

> enum Fred {ONE, TWO, THREE};

> or

> enum Fred {one, two, three};

I try to reserve all caps for identifiers that
are tinkered with by the preprocessor.

For enum members with scope outside of a single
file (defined in a .h file), I prefix the whole
set belonging to one enumeration by a few caps
that help avoid collisions with members from
other enumerations.  For example:
enum CommLineErrorLevel { // (CLEL_)
  CLEL_NoError = 0,
  CLEL_NoiseError,
  CLEL_NoResponse,
  CLEL_CountOf

Quote:
};

This makes it easy to grep for the other members
when you see one somewhere.

Completely lower case identifiers are reserved
for well-localized objects, such as formal
parameters and auto variables.

--
-Larry Brasfield
(address munged, s/sn/h/ to reply)



Thu, 17 Feb 2005 12:39:03 GMT  
 enum syntax
Thanks. By the way, what syntax do you use for enums without scope outside a
single file?

Regards.


Quote:


> > A question about your tastes in programming style: When defining enum
data,
> > do you prefer to write the enum elements in UPPER or lower case?

> > I.e.:

> > enum Fred {ONE, TWO, THREE};

> > or

> > enum Fred {one, two, three};

> I try to reserve all caps for identifiers that
> are tinkered with by the preprocessor.

> For enum members with scope outside of a single
> file (defined in a .h file), I prefix the whole
> set belonging to one enumeration by a few caps
> that help avoid collisions with members from
> other enumerations.  For example:
> enum CommLineErrorLevel { // (CLEL_)
>   CLEL_NoError = 0,
>   CLEL_NoiseError,
>   CLEL_NoResponse,
>   CLEL_CountOf
> };

> This makes it easy to grep for the other members
> when you see one somewhere.

> Completely lower case identifiers are reserved
> for well-localized objects, such as formal
> parameters and auto variables.

> --
> -Larry Brasfield
> (address munged, s/sn/h/ to reply)



Sat, 19 Feb 2005 14:48:08 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. enum: syntax question

2. 'C' enum syntax problem

3. C enum syntax problem

4. typedef enum syntax changed in VS.Net C++ ATL?

5. BUG: DEBUG member in enum in class syntax error C2059

6. typedef enum as subset of another enum

7. enum - enum ?

8. enum - enum ?

9. Enum on Hashtable help !

10. How to enum DirectoryEntries without foreach in C#??

11. enum and combo

12. Getting back int value from Enum?

 

 
Powered by phpBB® Forum Software