About enumerations in Delphi and c++ in 64-bit environments
- by sum1stolemyname
I recently had to work around the different default sizes used for enumerations in Delphi and c++ since i have to use a c++ dll from a delphi application.
On function call returns an array of structs (or records in delphi), the first element of which is an enum.
To make this work, I use packed records (or aligned(1)-structs). However, since delphi selects the size of an enum-variable dynamically by default and uses the smallest datatype possible (it was a byte in my case), but C++ uses an int for enums, my data was not interpreted correctly.
Delphi offers a compiler switch to work around this, so the declaration of the enum becomes
{$Z4}
TTypeofLight =
(
V3d_AMBIENT,
V3d_DIRECTIONAL,
V3d_POSITIONAL,
V3d_SPOT
);
{$Z1}
My Questions are:
What will become of my structs when they are compiled on/for a 64-bit environment?
Does the default c++ integer grow to 8 Bytes?
Are there other memory alignment / data type size modifications (other than pointers)?