LispWorks Foreign Language Interface User Guide and Reference Manual > 6 Type Reference



FLI type descriptor

Converts between a FLI array and a C array type.


:c-array type &rest dimensions



The type of the elements of the array.


A sequence of the dimensions of the new array.


The FLI :c-array type converts between FLI arrays and the C array type. 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.

When using the :c-array type in the specification of an argument to define-foreign-function, a pointer to the array is passed to the foreign function, as specified by the C language. You are allowed to call the foreign function with a FLI pointer pointing to an object of type type instead of a FLI array.

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


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


LispWorks Foreign Language Interface User Guide and Reference Manual - 21 Dec 2009