declaring C enum types
fjh at cs.mu.OZ.AU
Thu Oct 17 09:38:27 EDT 2002
On 17-Oct-2002, Michael Weber <michaelw at foldr.org> 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
No, this is wrong.
> [#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.
| 220.127.116.11 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
| Footnote 108:
| An implementation may delay the choice of which integer
| type until all enumeration constants have been seen.
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
More information about the FFI