A symbol naming the new structure type specifier
A string specifying the foreign name of the structure.
A symbol, or a list of symbol and type description, naming a slot in the structure
A symbol naming the slot
The foreign type of the slot
A list specifying byte packing for the subsequent slots
The number of 8-bit bytes to pack
define-c-struct is used to define a FLI structure type specifier, which corresponds to the C
struct type. It is a convenience function, as a structure type could also be defined using define-foreign-type.
A structure is an aggregate type, or collection, of other FLI types. The types contained in a structure are referred to as slots, and can be accessed using the foreign-slot-type and foreign-slot-value functions.
which causes fields in a structure to be aligned on a byte boundary even if their natural alignment is larger. This can be achieved from Lisp by specifying suitable byte-packing forms in the structure definition, as in the example below. Each byte-packing form specifies the packing for each slot-description that follows it in the
define-c-struct form. It is important to use the same packing as the C header file containing the foreign type.
An aligned form specifies that the next slot must be aligned on nbytes bytes. Note that this affects only the alignment of the next slot. It does not affect the length of the slot, or the alignment of other slots. You will need this when the slot is made to be aligned, for example in
gcc a slot defined like this:
int slot_name __attribute__ ((aligned (16))) ;
Finally an example to illustrate byte packing. This structure will require 4 bytes of memory because the field named a-short will be aligned on a 2 byte boundary and hence a byte will be wasted after the a-byte field:
LispWorks Foreign Language Interface User Guide and Reference Manual - 16 Feb 2015