[fpc-pascal] C Enum vs. Integer
    Jonas Maebe 
    jonas.maebe at elis.ugent.be
       
    Thu Sep 13 15:45:33 CEST 2012
    
    
  
Guillermo Martínez Jiménez wrote on Thu, 13 Sep 2012:
>> On 12 Sep 2012, at 19:11, Johann Glaser wrote:
>>
>>> Can I translate this 1:1, i.e., define an Enum in Pascal and just ignore
>>> the compiler warnings about reused values?
>>>
>>> Or should I rather define all these types as Integer and define
>>> constants for all values?
>>
>> It depends on whether you need arithmetic or not. If you do, use  
>> integer constants, otherwise you can use an enum.
>
> Actually you cannot.  FPC optimizes enumerations in some cases (i.e.
> in Delphi mode) but GCC uses 32bit for enumerations alwais.
The size of an enum in gcc depends on whether or not the -fshort-enums  
command line option is used, and on the number of bits required to  
represent its upper bound value.
> Anyway you can still use enums, but telling to FPC that you want to
> set its size by directives $PACKENUM and $ENUMSIZE.
It's $PACKENUM *or* $ENUMSIZE (they affect the same compiler setting)
Anwyay, yes, that's also what I said the part of my original mail that  
you cut away.
Jonas
    
    
More information about the fpc-pascal
mailing list