Delphi enumeration type length defaults to 2 bytes (word), and in C is enumerated as 4 bytes (double word), if you need to program across these two platforms, the transport structure will be caused by the data length of the disaster.
After looking for information, the original Delphi can be {$Z +} {$Z-} {$Z 1} {$Z 4} and other macros set the length of the enumeration type, as small as 1 bytes, as large as 4 bytes.
The official notes are as follows:
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/ Compdirsminimumenumerationsize_xml.html
The $Z directive controls the minimum storage size of Delphi enumerated types.
An enumerated type are stored as an unsigned byte if the enumeration have no more than values, and if the type was DECLA Red in the {$Z 1} state (the default). If an enumerated type have more than values, or if the type was declared in the {$Z 2} state, it is stored as a n unsigned word. Finally, if an enumerated type was declared in the {$Z 4} state, it's stored as an unsigned double word.
The {$Z 2} and {$Z 4} states is useful for interfacing with C and C + + libraries, which usually represent enumerated types as words or double words.
Note: Note: For backwards compatibility with early versions of Delphi and CodeGear Pascal, the directives {$Z-} and {$Z +< /c5>} is also supported. They correspond to {$Z 1} and {$Z 4}, respectively.
Examples are as follows:
Http://www.delphibasics.co.uk/RTL.asp?Name= $Z
Example code:various Enum type sizes
Type
{$Z1}
TCars1 = (Rover, Jaguar, Honda); //would fit into 1 byte
TFruit1 = (banana=255, Apple, Pear); //would exceed one byte
{$Z4}
TCars2 = (Ford, Nissan, Vauxhall); //Now uses 4 bytes
TFruit2 = (orange=255, Plum, Grape); //Now uses 4 bytes
Begin
ShowMessage (' TCars1 size = ' +inttostr (SizeOf (TCars1)));
ShowMessage (' TFruit1 size = ' +inttostr (SizeOf (TFruit1)));
ShowMessage (' TCars2 size = ' +inttostr (SizeOf (TCARS2)));
ShowMessage (' TFruit2 size = ' +inttostr (SizeOf (TFRUIT2)));
end;
TCars1 size = 1
TFruit1 size = 2
TCars2 size = 4
TFruit2 size = 4
Delphi Set Enumeration Type size