|
|
Harald van Dijk <truedfx@xxxxxxxxx> writes:
> Will an enumeration type always promote to signed or unsigned
> int, or can it also promote to something larger (both in theory
> and in practise)?
In theory, an implementation may choose any suitable integer
type:
Each enumerated type shall be compatible with char, a signed
integer type, or an unsigned integer type. The choice of type
is implementation-defined,108) but shall be capable of
representing the values of all the members of the
enumeration.
In practice, all the values of an enumeration must be in the
range of "int", so I would not expect a compiler to choose a type
wider than "int".
You could always remove all risk by transforming this code:
enum EnumerationType
{
Value1,
Value2,
Value3
};
into this:
enum
{
Value1,
Value2,
Value3
};
typedef int EnumerationType;
which is just about equivalent except that EnumerationType is
always int.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
|
|