Defines a Lisp function which, when passed a pointer to a foreign function, calls it.
fli
define-foreign-funcallable the-name args &key lambda-list documentation result-type language no-check calling-convention variadic-num-of-fixed => the-name
args ::= ({arg}*)
| the-name⇩ |
A symbol naming the Lisp function. |
| lambda-list⇩ |
The lambda list to be used for the defined Lisp function. |
| documentation⇩ |
A documentation string for the foreign function. |
| result-type⇩ |
A foreign type. |
| language⇩ |
The language in which the foreign source code is written. The default is :ansi-c. |
| no-check⇩ |
A boolean. |
| calling-convention⇩ |
Specifies the calling convention used. |
| variadic-num-of-fixed⇩ | |
nil or a non-negative integer. | |
| arg⇩ |
Argument specifier as in define-foreign-function. |
| the-name |
A symbol naming the Lisp function. |
The macro define-foreign-funcallable is like define-foreign-function, but creates a function with an extra argument at the start of the argument list for the address to call.
See define-foreign-function for how the-name, lambda-list, documentation, result-type, language, no-check, calling-convention, variadic-num-of-fixed and arg are used.
Define a caller for this shape:
(fli:define-foreign-funcallable call-with-string-and-int ((string (:reference-pass :ef-mb-string)) (value :int)))
Call printf. Note that the output goes to console output which is hidden by default:
(let ((printf-func
(fli:make-pointer :symbol-name "printf")))
(call-with-string-and-int
printf-func "printf called with %d" 1234))
Foreign Language Interface User Guide and Reference Manual - 18 Feb 2025 15:36:32