[fpc-devel] How to convert set to integer and vice versay

Marco van de Voort marcov at stack.nl
Tue Jul 22 18:13:56 CEST 2014


In our previous episode, Gennady Agranov said:
> >
> > Good. And afaik in Delphi mode this works too in FPC? Did you test?
> >
> 
> casting integer to set does not compile in FPC - and yes - I use Delphi
> mode :(

program setcast;

{$ifdef FPC}
{$mode delphi}
{$else}
{$APPTYPE CONSOLE}
{$endif}

uses
  SysUtils;

type tenum=0..31;
     tmyset= set of tenum;

var x:integer;
    y:tmyset;

begin
  x:=integer(y);
end.

compiles in both FPC (both 2.6.x and trunk) and Delphi (XE4)




More information about the fpc-devel mailing list