On Wed, Jul 29, 2009 at 11:29 PM, Roland Dreier<<a href="mailto:rdreier@cisco.com" target="_blank">rdreier@cisco.com</a>> wrote:<br>> By the way, I just did some research and<br>> <<a href="http://wiki.debian.org/ArmEabiPort#Enumsizes" target="_blank">http://wiki.debian.org/ArmEabiPort#Enumsizes</a>><br>
> indicates that on current arm ABI, enums are the same size as int.<br>><br>> and<br>> <<a href="http://developers.sun.com/solaris/articles/about_amd64_abi.html" target="_blank">http://developers.sun.com/solaris/articles/about_amd64_abi.html</a>><br>
> indicates that sparc32 and sparc64 both use int for enum.<br>><br>> and I found a mips cross compiler and tested there, and int works there<br>> as well.<br>><br>> So I'm pretty comfortable with this patch (once the man pages and other<br>
> doc get fixed to match the changes).<br><br>If I'm not mistaken, the ANSI/ISO C standard requires that enums have the same size as an int. Two quotes from <span style="font-weight: normal;">JTC1/SC22/WG14 working group, </span><i><a style="font-weight: normal;" rel="nofollow" href="http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.pdf" target="_blank">Draft standard for the ANSI C programming language</a></i><span style="font-weight: normal;">, August 3, 1998:</span><br>
<br>
<i>6.2.5 Types [ ... ] 16. An enumeration comprises a set of named integer constant values. Each distinct enumeration constitutes a different enumerated type.<br></i><br><i>6.7.2.2 Enumeration specifiers [ ... ] 2 The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an <b>int</b>.</i><br>
<br>This does not hold for C++ however. A C++ compiler may use an integral type larger or smaller than an int to represent an enumeration type. A quote from Bjarne Stroustrup, <i>The C++ Programming Language</i>, Special Edition, Addison Wesley, 2000:<br>
<br><i>The sizeof an enumeration is the sizeof some integral type that can hold its range and not larger size of size of than sizeof(int), unless an enumerator cannot be represented as an int or as an unsigned int.<br>
</i><br>Bart.<br>