Enum legality question

Henry Spencer henry at utzoo.uucp
Sat Jul 30 06:37:15 AEST 1988


In article <5390 at june.cs.washington.edu> pardo at cs.washington.edu (David Keppel) writes:
>I want to do something like:
>
>	enum zork_t { FOO, BAR, BAZ, ZORK, BORK, SPLODGE, SPLAT };
>	int a[6];
>	zork_t hoof;
>
>	a[FOO] = 23;
>	a[BAR] = 55;
>	for( hoof=BAZ; hoof<=SPLAT; ++hoof ){
>	    a[hoof] = 0;
>	}
>
>Question: which of these are legal under ANSI (proposed) C?

All of them, except that if I'm not mistaken you are assigning to a[6],
which does not exist.  Enums are just a way to write integer constants,
in essence.

Many existing compilers may object to some part of the above, but that's
a problem any time an old construct is liberalized.
-- 
MSDOS is not dead, it just     |     Henry Spencer at U of Toronto Zoology
smells that way.               | uunet!mnetor!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list