[fpc-pascal] Sets
Marco van de Voort
marcov at stack.nl
Wed Oct 2 22:23:38 CEST 2013
In our previous episode, Juha Manninen said:
[ Charset ISO-8859-1 unsupported, converting... ]
> 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!
Workse fine here:
{$mode delphi}
type
TMyEnum = (
xOne,
xTwo,
xThree,
xFour,
xFive
);
// Count <= 8, fits in one Byte
TMyEnums = set of TMyEnum;
var x :TMyenums;
y : byte;
begin
y:=byte(x);
end.
Hint: if you want delphi compatibility, use {$mode delphi} :-)
More information about the fpc-pascal
mailing list