Question about use of enum in typedef and struct
Wayne A. Throop
throopw at xyzzy.UUCP
Tue May 3 00:45:42 AEST 1988
> cavrak at 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 <the-known-world>!mcnc!rti!xyzzy!throopw
More information about the Comp.lang.c
mailing list