MacroPackage: ffToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version


Arguments: name arglist &rest body

This macro is obsolete and has been replaced by defun-foreign-callable. Please use that macro in all new code. This macro is maintained for backward compatibility only.

This macro defines a function in Lisp that can be called from foreign (traditionally C) code.

The argument list can be restated as:

lisp-function-name ({arg | (arg type)}*) body-form+ 

Thus arglist (the second argument in the argument list) is a list of arguments each of which is either a symbol (as in the usual function definition), or it is a list of length two, a symbol and its type. If a symbol only is present, then it has the default type (:signed-natural). Each is an argument which C passes to Lisp. This macro does not allow &rest or &optional arguments in the argument list. The type corresponds to a memref type (see memref and memref-int) and is limited to be one of the following:

:signed-byte 8 bits
:unsigned-byte 8 bits
:signed-word 16 bits
:unsigned-word 16 bits
:fixnum 30 bits
:signed-long 32 bits
:unsigned-long 32 bits
:signed-natural (the default)
:single-float, single-float 32 bits
:double-float, double-float 64 bits
:lisp (Assumes that C passes an actual Lisp value)

Warning for users of 64-bit Lisps: :signed-long and :unsigned-long are treated as 32-bit values, even on a 64-bit port. Contrast this to defun-foreign-callable, where :long and :unsigned-long match the precise meaning in C on the architecture in question. But note further that that does not mean they follow the 32/64-bit nature of the Lisp; for example, a :long foreign type on Compaq Alphas is always 64-bits, even for a 32-bit lisp. But this is consistent with C.

Warning about backward compatibility with release 5.0.1 and earlier: The default argument type is changed from :signed-long to :signed-natural. If a user has pre-6.0 code that explicitly specifies :signed-long, it is likely not to work on 64-bit ports, because :signed-long always specifies 32 bit values. If the user instead takes the default argument type, then the code will work in all 6.0 and pre-6.0 versions. If 32-bits is explicitly desired, however, then the :signed-long (or :unsigned-long) should be explicitly specified.

See memref and memref-int and foreign-functions.htm for general information on foreign functions in Allegro CL.

Copyright (c) 1998-2017, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2017.2.15.

Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version