[fpc-pascal] C Enum vs. Integer

Guillermo Martínez Jiménez gmartinez at burdjia.com
Thu Sep 13 15:31:45 CEST 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.

Anyway you can still use enums, but telling to FPC that you want to
set its size by directives $PACKENUM and $ENUMSIZE.

Guillermo "Ñuño" Martínez



More information about the fpc-pascal mailing list