From: Nate Eldredge 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: X-Complaints-To: newsabuse AT supernews DOT com User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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" 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