Package: cffi

Function foreign-slot-pointer

Lambda List

foreign-slot-pointer (ptr type slot-name)


ptr -- A pointer to a structure.
type -- A foreign structure type.
slot-names -- A slot name in the type.
pointer -- A pointer to the slot slot-name.


Returns a pointer to the location of the slot slot-name in a foreign object of type type at ptr. The returned pointer points inside the structure. Both the pointer and the memory it points to have the same extent as ptr.

For aggregate slots, this is the same value returned by foreign-slot-value.


  (defcstruct point
    "Pointer structure."
    (x :int)
    (y :int))

CFFI> (with-foreign-object (ptr 'point) (foreign-slot-pointer ptr 'point 'x)) => #<FOREIGN-ADDRESS #xBFFF6E60> ;; Note: the exact pointer representation varies from lisp to lisp.

See also