Returns the offset of a slot in a FLI object.
fli
foreign-slot-offset object-or-type slot-name => offset
object-or-type⇩ |
A foreign object, a pointer to a foreign object, or a foreign structure or union type. |
slot-name⇩ |
A symbol or a list of symbols identifying the slot to be accessed, as described for foreign-slot-value. |
offset |
The offset, in bytes, of the slot slot-name in the FLI object object. |
The function foreign-slot-offset
returns the offset, in bytes, of the slot slot-name in object-or-type. The offset is the number of bytes from the beginning of the object to the start of the slot. For example, the offset of the first slot in any FLI object is 0.
The following example defines a structure, creates an instance of the structure pointed to by dir
, and then finds the offset of the third slot in the object.
(fli:define-c-struct compass (east :int) (west (:c-array :char 20)) (north :int) (south :int)) (fli:foreign-slot-offset 'compass 'north) (setq dir (fli:allocate-foreign-object :type 'compass)) (fli:foreign-slot-offset dir 'north)
Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58