Next: Arrays Unions Enums, Previous: Structures, Up: Types [Index]
libffi
will set the size
and alignment
fields of
an ffi_type
object for you. It does so using its knowledge of
the ABI.
You might expect that you can simply read these fields for a type that
has been laid out by libffi
. However, there are some caveats.
libffi
until it has been passed to ffi_prep_cif
.
So, before examining these fields, it is safest to pass the
ffi_type
object to ffi_prep_cif
first. This function
will do all the needed setup.
ffi_type *desired_type; ffi_abi desired_abi; … ffi_cif cif; if (ffi_prep_cif (&cif, desired_abi, 0, desired_type, NULL) == FFI_OK) { size_t size = desired_type->size; unsigned short alignment = desired_type->alignment; }