$PACKENUM or $Z : Minimum enumeration type size

[next] [prev] [prev-tail] [tail] [up]

#### 1.2.59 $PACKENUM or $Z : Minimum enumeration type size

This directive tells the compiler the minimum number of bytes it should use when storing enumerated types. It is of the following form:

{$PACKENUM xxx}
{$MINENUMSIZE xxx}

Where the form with $MINENUMSIZE is for Delphi compatibility. xxx can be one of 1,2 or 4, or NORMAL or DEFAULT (or 0).

The default enumeration size depends on the compiler mode:

- In Delphi and TP mode, the size is 1.
- In MacPas mode, the size is 2.
- In all other modes, the default is 4.

As an alternative form one can use {$Z1}, {$Z2}{$Z4}. The {$Z} form takes a +/- argument, where + is equivalent to {$Z4} and - is equivalent to {$Z1}.

So the following code

{$PACKENUM 1}
Type
Days = (monday, tuesday, wednesday, thursday, friday,
saturday, sunday);

will use 1 byte to store a variable of type Days, whereas it normally would use 4 bytes. The above code is equivalent to

{$Z1}
Type
Days = (monday, tuesday, wednesday, thursday, friday,
saturday, sunday);

or equivalent to

{$Z-}
Type
Days = (monday, tuesday, wednesday, thursday, friday,
saturday, sunday);

[next] [prev] [prev-tail] [front] [up]