Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Apr 2015 12:59:00 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        David Chisnall <theraven@FreeBSD.org>, John Baldwin <jhb@FreeBSD.org>, Justin Hibbits <jhibbits@FreeBSD.org>, src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org
Subject:   Re: svn commit: r281721 - head/sys/sys
Message-ID:  <20150421095900.GL2390@kib.kiev.ua>
In-Reply-To: <20150421184157.Y2048@besplex.bde.org>
References:  <201504190033.t3J0XMDX041769@svn.freebsd.org> <476583045.Qcb6O2DFtY@ralph.baldwin.cx> <20150421020808.D10623@besplex.bde.org> <785A553E-317E-4C80-83A0-567C80697ED8@FreeBSD.org> <20150421184157.Y2048@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Apr 21, 2015 at 07:32:30PM +1000, Bruce Evans wrote:
> On Tue, 21 Apr 2015, David Chisnall wrote:
> 
> > On 20 Apr 2015, at 17:19, Bruce Evans <brde@optusnet.com.au> wrote:
> >>
> >> Enums should never be used in ABIs, since their size can be anything
> >> large enough.
> >
> > The rules for the size of enums also differ between C and C++, though clang (and, I think, gcc) support an attribute for specifying the enum type.
> >
> >> They also cause namespace problems.  The whole enum declaration must
> >> be exposed in any header that uses an enum type.
> >
> > Both C and C++ permit forward declarations of enums for use in function prototypes and so on, e.g.:
> >
> > enum foo;
> > void
> > bar(enum foo);
> 
> No, they cannot do this since the size may depend on the internals of the
> enum:
> 
> TendDRA-5.0.0:
> "z.c", line 1: Error:
>    [ISO C90 6.5.2.3]: Can't declare the enumeration 'enum foo'.
> 
This is not true for C.  The i386 ABI specification, from year _1997_,
states that enum must be 4-bytes unsigned entity, 4-bytes aligned.  See page
28 of abi386-4.pdf.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150421095900.GL2390>