Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2024-11

packed enum too small?

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Frb

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?

Reply by email