Enumeration types are supported in Free Pascal. On top of the Turbo Pascal implementation, Free Pascal allows the following C-style extension of the enumeration type.
Type EnumType = (one, two, three, forty := 40);As a result, the ordinal number of forty is 40, and not 4, as it would be when the '= 40' wasn't present.
When specifying such an enumeration type, it is important to keep in mind that you should keep initialized set elements in ascending order. The following will produce a compiler error:
Type EnumType = (one, two, three, forty := 40, thirty:=30);It is necessary to keep forty and Thirty in the correct order.
Remarks :
Type
LargeEnum = ( BigOne, BigTwo, BigThree );
{$PACKENUM 1}
SmallEnum = ( one, two, three );
Var S : SmallEnum;
L : LargeEnum;
begin
Writeln ('Small enum : ',Sizeof(S));
Writeln ('Large enum : ',SizeOf(L));
end.
will, when run, print the following:
Small enum : 1 Large enum : 4