Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!eagle!icdoc!cam-cl!am From: am@cl.cam.ac.uk (Alan Mycroft) Newsgroups: comp.lang.c Subject: Re: enum - enum ? Message-ID: <726@jenny.cl.cam.ac.uk> Date: Fri, 12-Jun-87 07:46:38 EDT Article-I.D.: jenny.726 Posted: Fri Jun 12 07:46:38 1987 Date-Received: Sun, 21-Jun-87 15:01:09 EDT References: <139@starfire.UUCP> <5959@brl-smoke.ARPA> Reply-To: am@cl.cam.ac.uk (Alan Mycroft) Organization: U of Cambridge Comp Lab, UK Lines: 21 In article <5959@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >As I recall, enums are now officially ints in disguise. Hmm. Checking in the draft (p54 para at line 40) seems to agree with this, but lets consider: enum joke { a=0, b=999999999 }; what happens if 'int' is only 16 bits? Does 'b == 999999999 & 0xffff'? Similarly, consider enum { a = ~0U } on a 32 bit two's complement machine. What is 'a/2'? is it -1/2 (probably 0) or 0x7fffffff? Consider sizeof too: "The implementation many use the set of values ... to allocate ... storage". What does this mean for: enum query { zero=0, one=1 } q; The spec. says zero is int hence sizeof(zero) = sizeof(int). On the other hand sizeof(q) maay be sizeof(char). Is this reasonable? What about sizeof(q)?