All Manuals > Foreign Language Interface User Guide and Reference Manual > 7 Function, Macro and Variable Reference

foreign-array-pointer Function

Summary

Returns a pointer to a specified element in an array.

Package

fli

Signature

foreign-array-pointer array &rest subscripts => pointer

Arguments
array
A FLI array or a pointer to a FLI array.
subscripts
A list of valid array indices for array.
Values
pointer
A pointer to the element at position subscripts in array.
Description

The function foreign-array-pointer returns a pointer to an element in array specified by subscripts. You can then use dereference or foreign-slot-value to access the value.

Examples

In this example a 3 by 2 array of integers is created, and a pointer to the element at position 2 0 is returned using foreign-array-pointer.

(setq array1 (fli:allocate-foreign-object 
              :type '(:c-array :int 3 2)))
(setq array-ptr (fli:foreign-array-pointer array1 2 0))

The setf form of dereference can now be used to set the value pointed to by array-ptr.

(setf (fli:dereference array-ptr) 42)
See also

foreign-aref
foreign-array-dimensions
foreign-array-element-type


Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58