Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/26/03 22:37
Read: times


 
#40180 - RE: enumerated constants in c
Responding to: ???'s previous message
Jez:
Enumerated constants in C are not I think at all what you wanted to use. In C the enumeration is a mechanism primarily used to create a set of names that you typically have the compiler set the corresponding values for. (Altho there is the = assignment you can do in an enumeration initialization to force one or more elements in the set to have a specific value).

It can be frustrating in C becasue enumerations have somewhat limited usefulness. They work good for switch statement case values, and the work good for packet function code constants etc etc. But they are next to worthless for use as indexes to the likes of arrays of structures. You end up having to put an extra byte or word in each structure element and initialize it to the enumeration name. Then at run time to find something in the table it is necessary to scan the structure table to find the element in question...oh well.....after years I quit letting it frustrate me and move on!!
Michael Karas


List of 4 messages in thread
TopicAuthorDate
enumerated constants in c            01/01/70 00:00      
   RE: enumerated constants in c            01/01/70 00:00      
   RE: enumerated constants in c            01/01/70 00:00      
      RE: enumerated constants in c            01/01/70 00:00      

Back to Subject List