Subject: [clisp-list] FFI with a .dll

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Fri Feb 28 01:24:17 2003

Matthew Williams wrote:
>I have a .c function that has been compiled into a
>.dll file.  I want to use FFI to call that function
You cannot make use of a .dll for now unless you apply the patch that I sent to this list around March 2002. I'm sorry that I did not finalize that. It's certainly needed.

What you can do instead is (if you can compile CLISP from sources) to have your C function in a standard .obj file. Then compile your file containing def-call-out. This will generate a C interface file to your function (by creating what CLISP calls an external module). Then you link all of this into a new lisp.exe binary (and must edit modules.h prior to that).

I have written a MS-Word document (available in .doc and .pdf) that goes into details. Sent me private e-mail if you need that.

>foo.c
>__declspec(dllexport) int foo()
>{   return 99;
>}

>(ffi:def-call-out foo
>  (:arguments (nil nil))
Just omit :arguments or put an empty list [()]. (nil nil) is not the way to declare this case.
>  (:return-type ffi:int)
>  (:language :c)
These days you should probably use :language :stdc (means ANSI C)

Regards,
	Jorg Hohle.