Article View: net.lang.c
Article #9686Re: what type is enum ?
From: Henry Spencer
Date: Fri, 31 Oct 1986 22:59
Date: Fri, 31 Oct 1986 22:59
22 lines
1783 bytes
1783 bytes
> Is enumeration a fundamental or derived type considering
> that it always behaves as int according to X3JJ11 ?
> It seems to have problems being either one.
Neither. In X3J11speak, enum is not a distinct type at all. It's just a
way of giving names to a bunch of integer constants. Your compiler might
helpfully (?) provide warning messages unless you treat it strictly as a
distinct type, but that is not an X3J11 requirement.
It is agreed that this is not terribly satisfactory, but then enums never
were terribly satisfactory. The way existing compilers treat them is best
described as "confused". Thus X3J11 had to decide between trying to compose
a complete and consistent specification for their current behavior (probably
impossible), making them distinct types a la Pascal (which would break a lot
of existing C code), or simplifying them to named integer constants (less
than elegant, but the only practical approach). Actually, there was a fourth
choice: delete them from C altogether, leaving them as a non-standard
extension in some existing compilers. I gather there was long debate about
the matter (I'm not formally involved with X3J11, so I can't say for sure).
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,decvax,pyramid}!utzoo!henry
Technical Details
Message-ID:
<7273@utzoo.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<1640@mtx5a.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: what type is enum ? Message-ID: <7273@utzoo.UUCP> Date: Fri, 31-Oct-86 17:59:01 EST Article-I.D.: utzoo.7273 Posted: Fri Oct 31 17:59:01 1986 Date-Received: Fri, 31-Oct-86 17:59:01 EST References: <1640@mtx5a.UUCP> Organization: U of Toronto Zoology Lines: 22