NextPrevUpTopContentsIndex

:c-array

FLI type descriptor
Summary

Converts between a Lisp array and a C array.

Package

fli

Syntax

:c-array type &rest dimensions

Arguments

type

The type of the elements of the array.

dimensions

A sequence of the dimensions of the new array.

Description

The FLI :c-array type converts between Lisp structures and C arrays. In C, pointers are used to access the elements of an array. The implementation of the :c-array type takes this into account, by automatically dereferencing any pointers returned when accessing an array using foreign-aref, unlike :foreign-array

Note that :c-array uses the C convention that the first index value of an array is 0 .

Example

The following code defines a 3 by 3 array of integers.

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

The next example defines an array of arrays of bytes.

(setq array2 (fli:allocate-foreign-object
              :type '(:c-array (:c-array :byte 3) 2)))

See foreign-aref and foreign-array-pointer for more examples on the use of arrays.

See also

foreign-aref
:foreign-array
foreign-array-pointer


LispWorks Foreign Language Interface User Guide and Reference Manual - 27 Mar 2005

NextPrevUpTopContentsIndex