The interface is the function foreign-parser:process-foreign-file.
Suppose we wish to generate the FLI definitions which interface to the C example from Modifying a string in a C function. The header file
test.h
needs to be slightly different depending on the platform.
__declspec(dllexport) void __cdecl modify(char *string)
void modify(char *string)
(require "foreign-parser")
(foreign-parser:process-foreign-file
"test.h"
:case-sensitive nil)
=>
;;; Output dff file #P"test-dff.lisp"
;;; Parsing source file "test.h"
;;; Process-foreign-file : Preprocessing file
;;; Process-foreign-file : Level 1 parsing
;;; Process-foreign-file : Selecting foreign forms
NIL
test-dff.lisp
containing a form like this:(fli:define-foreign-function
(modify "modify" :source)
((string (:pointer :char)))
:result-type
:void
:language
:c
:calling-convention
:cdecl)
:ef-mb-string
:(fli:define-foreign-function
(modify "modify" :source)
((string (:reference (:ef-mb-string :limit 256))))
:result-type
:void
:language
:c
:calling-convention
:cdecl)
=>
MODIFY
(fli:register-module "test.dll")
(fli:register-module "/tmp/test.so")
(modify "Hello, I am in LISP")
=>
NIL
"'Hello, I am in LISP' modified in a C function"
LispWorks Foreign Language Interface User Guide and Reference Manual - 7 Dec 2011