March 2000
Intermediate to advanced
576 pages
18h 13m
English
$MinEnumSize Compiler Directive
{$Z1} // default
{$MinEnumSize 1} // default
{$Z2}
{$Z4}
{$MinEnumSize 2}
{$MinEnumSize 4}
{$Z-} // obsolete, means {$Z1}
{$Z+} // obsolete, means {$Z4}Local
The $MinEnumSize
compiler directive sets the smallest
size (in bytes) that Delphi uses for an enumerated type. The default
is 1 byte, which means Delphi uses the size that is most appropriate.
An enumeration with up to 256 literals fits in 1 byte, and an
enumeration with up to 65,568 literals fits into 2 bytes.
If you have an enumerated type that must be compatible with an
enum in a C or C++ program, you can adjust the
size of the enumerated type for compatibility. Usually, that means
setting the minimum enumeration size to
4.
{$MinEnumSize 4} // Increase the size for C compatibility.
type
TCEnum = (cRed, cBlack);
{$MinEnumSize 1} // Restore the default.
function GetColor: TCEnum; external 'cdemo.dll';| Type Keyword |
Read now
Unlock full access