[fpc-pascal] Sets

Juha Manninen juha.manninen62 at gmail.com
Wed Oct 2 19:09:25 CEST 2013

If I have have a set with < 9 elements, like :

  TMyEnum = (
  // 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.


More information about the fpc-pascal mailing list