delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/28/16:15:24

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Size_Of in DJGPP...Bug?
Date: 28 Jun 2000 13:08:23 -0700
Organization: Posted via Supernews, http://www.supernews.com
Lines: 20
Sender: nate AT mercury DOT bitbucket
Message-ID: <83lmzpmuvc.fsf@mercury.bitbucket>
References: <u9hmjs4dknggq2jboelfo8o4pv0b0op60h AT 4ax DOT com> <m1r65.110534$6t3 DOT 155967 AT afrodite DOT telenet-ops DOT be>
X-Complaints-To: newsabuse AT supernews DOT com
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Tim \"Zastai\" Van Holder" <zastai AT hotmail DOT com> writes:

> This seems exctly right to me. 'enum' isn't a type, so the sizeof operator
> can't legally be applied to it.
> 'enum foo', 'enum bar' and 'enum foobar' ARE type, and you can apply sizeof
> to them. Note that in theory, the compiler is allowed to decide the size of
> an enum by looking at the range of values it contains; an enum containing
> just values between -127 and 128 (or between 0 and 255) could be put in
> single byte, while an enum using -12 and 2375 would require 2 bytes, and so
> on. in practice, usually an int is used, as shown below:
[...]
> NOTE: Optimizations (including -Os) do NOT affect this -- gcc always uses
> int-sized storage for enums.

Unless you specify -fshort-enums.

-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019