Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!uwm.edu!linac!unixhub!stanford.edu!eos!aio!gothamcity.jsc.nasa.gov!bill From: bill@gothamcity.jsc.nasa.gov (Bill Shirley) Newsgroups: comp.lang.c Subject: enum style Keywords: enum type enumerated style Message-ID: <1991May27.175350.26033@aio.jsc.nasa.gov> Date: 27 May 91 17:53:50 GMT Sender: shirley@gothamcity.jsc.nasa.gov (Bill Shirley) Organization: Software Technology Branch - NASA/JSC Lines: 37 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@gothamcity.jsc.nasa.gov |_| |_|ciences |_| _______________________________ _omputer _ _ Opinions expressed are obtained| | |___ ___| | | |___orporation by a room full of immortal apes| \____| |____/ \____| with unbreakable typewriters. | ~~~~~~~~~~~DISCLAIMER~~~~~~~~~~~