Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Enum legality question
Message-ID: <1988Jul29.203715.28345@utzoo.uucp>
Organization: U of Toronto Zoology
References: <5390@june.cs.washington.edu>
Date: Fri, 29 Jul 88 20:37:15 GMT

In article <5390@june.cs.washington.edu> pardo@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@zoo.toronto.edu
