[fpc-devel] packed enum too small?

Martin Frb lazarus at mfriebe.de
Wed Nov 13 16:50:13 CET 2024


The below gives a size of 1 byte => meaning that both values are the 
same $FF


program Project1;
{$PackEnum 1}
type
   Tfoo = (f1=-1, f2=255);
var
   a,b: TFoo;
begin
   writeln(SizeOf(TFoo));
   a:= f1;
   b:= f2;


   b:= f2;
end.


Changing it to:
   Tfoo = (f1=-129, f2=255);

gives a size of 2 bytes.


It seems the range that returns 1 byte goes from -127 to 255 => which is 
clearly more than fits into one byte?



More information about the fpc-devel mailing list