[fpc-pascal] Sets

Peter peter at pblackman.plus.com
Wed Oct 2 20:29:26 CEST 2013


Perhaps you need the {$PACKENUM n} compiler directive for the enumerated
type?


On 02/10/13 18:09, Juha Manninen wrote:
> If I have have a set with < 9 elements, like :
>
> type
>   TMyEnum = (
>     xOne,
>     xTwo,
>     xThree,
>     xFour,
>     xFive
>   );
>   // Count <= 8, fits in one Byte
>   TMyEnums = set of TMyEnum;
>
> then in Delphi a variable of that type can be casted to Byte. Other
> casts don't work.
> In FPC I must cast it to Integer!
> Does it really mean that all sets in FPC reserve at least 32 bits? Is
> it documented? I did not find it as "Set" gives so many false matches.
>
> I hope the implementation is otherwise compatible with Delphi, meaning
> that the bits start from LSB always. I rely now on this implementation
> detail. There is code that transfers bitfields between computers.
> Using type checking and descriptive names makes the code better in
> many ways, compared to using integers & AND operator.
>
> Juha
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>




More information about the fpc-pascal mailing list