enum style

Bill Shirley bill at gothamcity.jsc.nasa.gov
Tue May 28 03:53:50 AEST 1991


I started using a certain stype in enumerated type definitions 
and would like to know other C peoples' opinions about it.
I'm mostly concerned with readability/maintainability/portability.

If I have made assumptions that may not be true across all platforms
*please* tell me!

here goes...

typedef enum {	NoState,
	STATE_A, STATE_B, STATE_C, /* ... */
		NUM_STATES } State;


As a side note, I have found this to be extremely useful in debugging
where I used to have many, many #define statements for many different things!


I am correct in assuming that NUM_STATES will be the correct value always,
aren't I?

using it in cases such as:

char	*name_of_state[NUM_STATES];

(the 'zero' element normally is not used)


Anyway, I'd like to hear others' opinions (pro or con).

     ____     ____       ____			Bill Shirley
    / ___|   / ___|     / ___|			bill at gothamcity.jsc.nasa.gov
   |_|      |_|ciences |_|			_______________________________
    _omputer     _      _			Opinions expressed are obtained|
   | |___    ___| |    | |___orporation		by a room full of immortal apes|
    \____|  |____/      \____|			with unbreakable typewriters.  |
  						~~~~~~~~~~~DISCLAIMER~~~~~~~~~~~



More information about the Comp.lang.c mailing list