Next: , Previous: foreign-slot-offset, Up: Foreign Types


foreign-slot-pointer

Syntax

— Function: foreign-slot-pointer ptr type slot-name ⇒ pointer

Arguments and Values

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.

Description

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.

Examples

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

See Also

defcstruct
foreign-slot-value
foreign-slot-names
foreign-slot-offset