Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!cjc From: cjc@ulysses.att.com (Chris Calabrese) Newsgroups: comp.lang.c Subject: Re: Enumerated types... what's the point? Summary: ordering is defined by ansi Keywords: C, enum Message-ID: <12719@ulysses.att.com> Date: 24 Mar 90 00:06:47 GMT References: <1480@mountn.dec.com> Distribution: usa Organization: AT&T Bell Laboratories, Murray Hill Lines: 23 In article <1480@mountn.dec.com>, wallis@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@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@ulysses.att.com Obligatory Quote: ``Anyone who would tell you that would also try and sell you the Brooklyn Bridge.''