Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!ncsuvx!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Question about use of enum in typedef and struct Message-ID: <831@xyzzy.UUCP> Date: 2 May 88 14:45:42 GMT References: <823@uvm-gen.UUCP> Organization: Data General, RTP NC. Lines: 31 > cavrak@uvm-gen.UUCP (Steve Cavrak) > Can someone explain why the following uses (abuses?) of typdef and enum > create problems [...] > typedef int s_state_ok; > typedef enum s_state_ok { > initial_ok, middle_ok, final_ok > }; Saying typedef enum foo {a, b, c}; is about like saying typedef int; or typedef struct foo {int a;int b;int c}; In none of these three cases has a new type name been introduced. Presumably what was meant was typedef enum { initial_ok, middle_ok, final_ok } s_state_ok; The first line where s_state_ok is typedef'ed to be an (int) is not necessary (or legal, or wanted) once it has correctly been coined as an enum type. -- You can lead a yak to water but you can't teach an old dog to make a silk purse out of a pig in a poke. --- Opus -- Wayne Throop !mcnc!rti!xyzzy!throopw