Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.UUCP Newsgroups: net.lang.c Subject: Re: Crossing enumeration types Message-ID: <4278@sun.uucp> Date: Thu, 19-Jun-86 15:01:36 EDT Article-I.D.: sun.4278 Posted: Thu Jun 19 15:01:36 1986 Date-Received: Sat, 21-Jun-86 10:45:15 EDT References: <1202@brl-smoke.ARPA> Organization: Sun Microsystems, Inc. Lines: 35 > enum days {mon, tue,wed} day; > enum colors {red,green,blue} color; > > main () > { > day = green; > set_color (day); > } > set_color(thiscolor) > enum colors thiscolor; > {... > } > > Is this program legal according to s strict interpretation of the new > ANSI standard? Yes. "enum"s are just fancy integral types, whose values have names. > By common usage? Yes, in the sense that the code will compile and do what you'd expect it to do given that "enum"s are fancy "int"s. > Is this something lint should/does complain about? It does complain; I would argue that it should. The complaints should be warnings, since the code is technically correct. However, the code stands a good chance of being in error anyway, so the complaints are justified. Casts should suppress the complaint, so that if this is what the person intended to do they can say so. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)