declaring C enum types

Fergus Henderson fjh at
Thu Oct 17 09:38:27 EDT 2002

On 17-Oct-2002, Michael Weber <michaelw at> wrote:
> On Thu, Oct 17, 2002 at 02:25:44AM -0700, John Meacham wrote:
> > I am pretty sure that ISO C says that enums are equivalant to ints
> > always. of course, not all implementations may be ISO C compliant.
> > 	John
> Right.

No, this is wrong.

> C99#
> [...]
> [#2] An identifier declared as an enumeration  constant  has
>      type int.

The enumeration constants have type `int'.
However, the enumeration type itself is a different type.
The enumeration type need not have the same size or representation as int.

 |  Enumeration specifiers
 | [#4]   Each enumerated type shall be compatible with  char,  a
 |        signed  integer  type,  or  an  unsigned  integer type.  The
 |        choice  of  type is implementation-defined, but shall be
 |        capable of representing the values of all the members of the
 |        enumeration.

 | Footnote 108:
 |        An implementation may delay the choice of  which  integer
 |        type until all enumeration constants have been seen.

Fergus Henderson <fjh at>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

More information about the FFI mailing list