AW: [cffi-devel] vararg / New foreign library interface

Luís Oliveira luismbo at gmail.com
Mon Jan 9 12:36:26 UTC 2006


On 2006-jan-09, at 09:30, Hoehle, Joerg-Cyril wrote:
>> (with-default-library ("msvcrt.dll")
>>  (defcfun "sprintf" :int
> Quite reasonable, as one can expect many files to have this structure:
> binding-to-XYZ.lisp
> (set-library-somehow XYZ)
> (defcfun x [in XYZ])
> (defcfun y [in XYZ])

I kind of like this way.

(define-foreign-library foo
   ...)

(use-foreign-library foo)

(defcvar "variable-in-library-foo")

(defcfun "function-in-library-foo"
   ...)


But, unfortunately, using this approach it might be easy to produce  
bindings that work in lisps that do global lookup and don't work on  
other lisps.

Regarding passing options to defcfun, my personal favourite is:

   (defcfun "foo" :rettype
       ((arg1 :type1)
        (arg2 :type2))
     :library bar
     :calling-convention xpto)

But I don't feel strongly about it. Either one of the options James  
sketched in his e-mail look good to me.

Also, define-foreign-library should probably be extended to take a  
calling convention argument though ideally, IMHO, every Lisp would be  
like Allegro in this regard and we wouldn't have to pick between  
cdecl and stdcall and it would work with either calling convention.

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt




More information about the cffi-devel mailing list