Enumerated types... what's the point?
Chris Calabrese
cjc at ulysses.att.com
Sat Mar 24 10:06:47 AEST 1990
In article <1480 at mountn.dec.com>, wallis at labc.dec.com (Barry L. Wallis) writes:
| Is ordering defined on type enum? I have a book on Turbo-C (can't remember the
| title but it's published by Howard Sams) which says that ordering on the
| elements of an enum is undefined. For example, enum { JAN, FEB, MAR } months
| would make the comparison (FEB > JAN) illegal! I don't believe this is reality
| in Turbo-C, but, I'm currently 1700 miles from my PC and library.
| Barry L. Wallis USENET: wallis at labc.dec.com
| Database Consultant Prodigy (don't laugh): DNMX41A
| U.S. DECtp Resource Center DECUServe: EISNER::WALLIS (not on the net yet)
| Los Angeles, CA "No one voted for me, I represent myself"
If I remember correctly, ANSI says that the enums are to be stored as
ints and that they are ordered from 0 to n, unless the programmer
states otherwise (I think the syntax is enum {bar=5, foo, bugger ...).
Don't remember if (FEB > JAN) works, but ((int)FEB > (int)JAN)
definitely works.
--
Name: Christopher J. Calabrese
Brain loaned to: AT&T Bell Laboratories, Murray Hill, NJ
att!ulysses!cjc cjc at ulysses.att.com
Obligatory Quote: ``Anyone who would tell you that would also try and sell you the Brooklyn Bridge.''
More information about the Comp.lang.c
mailing list