All Manuals > Foreign Language Interface User Guide and Reference Manual > 7 Function, Macro and Variable Reference

define-foreign-funcallable Macro

Summary

Defines a Lisp function which, when passed a pointer to a foreign function, calls it.

Package

fli

Signature

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}*)

Arguments
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.
Values
the-name
A symbol naming the Lisp function.
Description

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.

Examples

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))
See also

define-foreign-function


Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58