svn commit: r281721 - head/sys/sys

Konstantin Belousov kostikbel at gmail.com
Tue Apr 21 09:59:06 UTC 2015


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 at 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.


More information about the svn-src-head mailing list