All Manuals > LispWorks Foreign Language Interface User Guide and Reference Manual > 2 FLI Types

NextPrevUpTopContentsIndex

2.1 Immediate types

The immediate types are the basic types used by the FLI to convert between Lisp and a foreign language.

The immediate types of the FLI are :boolean, :byte, :char, :const, :double, :enum, :float, :int, :lisp-double-float, :lisp-float, :lisp-single-float, :long, :pointer, :short, :signed and :unsigned. For details on each immediate type, see the relevant reference entry.

2.1.1 Integral types

Integral types are the FLI types that represent integers. They consist of the following: :int, :byte, :long, :short, :signed, :unsigned and :enum, along with integer types converting to types with particular sizes defined by ISO C99 such as :int8, :uint64 and :intmax.

Integral types can be combined in a list for readability and compatibility purposes with the foreign language, although when translated to Lisp such combinations are usually returned as a Lisp integer, or a fixnum for byte sized combinations. For example, a C unsigned long can be represented in the FLI as an (:unsigned :long).

2.1.2 Floating point types

The FLI provides several different immediate types for the representation of floating point numbers. They consist of the following: :float, :double, :lisp-double-float, :lisp-float, and :lisp-single-float. The floating types all associate equivalent Lisp and C types, except the :lisp-float, which can take a modifier to cause an association between different floating types. A :lisp-float associates a Lisp float with a C float by default, but a declaration of (:lisp-float :double) corresponds to a C double, for example.

Note: be sure to use :language :ansi-c when passing float arguments to and from C using define-foreign-function and so on.

2.1.3 Character types

The FLI provides the :char type to interface a Lisp character with a C char.

2.1.4 Boolean types

The FLI provides the :boolean type to interface a Lisp boolean value (t or nil) with a C int (0 corresponding to nil, and any other value corresponding to t). The :boolean type can be modified to make it correspond with other C types. For example, (:boolean :byte) would associate a Lisp boolean with a C byte, and (:boolean :long) would associate a Lisp boolean with a C long.

2.1.5 Pointer types

Pointers are discussed in detail in FLI Pointers. Further details can also be found in the reference entry for :pointer.


LispWorks Foreign Language Interface User Guide and Reference Manual - 16 Feb 2015

NextPrevUpTopContentsIndex