RE: Wrong warning? ISO C restricts enumerator values to range of ‘int’

Dave Korn dave.korn@artimi.com
Wed Feb 6 14:59:00 GMT 2008


On 06 February 2008 13:01, Felipe Contreras wrote:

> On Feb 6, 2008 2:47 PM, Andreas Schwab <schwab@suse.de> wrote:
>> "Felipe Contreras" <felipe.contreras@gmail.com> writes:
>> 
>>> This is what ISO C says:
>>> 
>>> Each enumerated type shall be compatible with char, a signed integer
>>> type, or an unsigned integer type. The choice of type is
>>> implementation-defined,110) but shall be capable of representing the
>>> values of all the members of the enumeration.
>> 
>> The standard also says:
>> 
>>   The expression that defines the value of an enumeration constant shall
>>   be an integer constant expression that has a value representable as an
>>   int.
> 
> Ahh, I see. So even if the type of the enum is specified by the
> compiler as "unsigned int"; the value assigned to it can only be an
> "int".

  So, how about

 typedef enum OMX_ERRORTYPE
 {
   OMX_ErrorNone = 0,
   OMX_ErrorInsufficientResources = (int)0x80001000
 } OMX_ERRORTYPE;

?



    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....



More information about the Gcc mailing list