[Ecls-list] MSVC FFI problems

Tomi Neste tomi.neste at netikka.fi
Sun Dec 30 01:14:25 UTC 2007


Greetings. I'm having some problems with the latest MSVC compiled ECL and  
UFFI:

1) When compiling a file with (UFFI:LOAD-FOREIGN-LIBRARY "some.dll") in it  
the compiler tries to link with the .dll of the library which won't work.  
If the "some.dll" is changed to "some.lib" it compiles but won't load.  
Everything works fine is I use

(PROGN
   (EVAL-WHEN (:COMPILE-TOPLEVEL) (FFI::DO-LOAD-FOREIGN-LIBRARY "some.lib"  
NIL))
   (SI:LOAD-FOREIGN-MODULE "some.dll"))


2) There is something funny happening when I try to declare foreign  
functions with :FLOAT arguments. Short example:

---------------------------------------------------

/* File ffi-test.c */
/* Compiled with "cl /LD ffi-test.c" */

float __declspec(dllexport) ffi_test(float a)
{
   return a;
}

----------------------------------------------------

;; File test.lisp using ffi-test.dll

(PROGN
   (EVAL-WHEN (:COMPILE-TOPLEVEL) (FFI::DO-LOAD-FOREIGN-LIBRARY  
"ffi-test.lib" NIL))
   (SI:LOAD-FOREIGN-MODULE "ffi-test.dll"))


(uffi:def-function ("ffi_test" ffi-test)
     ((a :float))
   :returning :float)


---------------------------------------------------

When I compile and load the files I get seemingly random results from  
FFI-TEST, with occasional DIVIDE-BY-ZERO. Any clues?


-- 
tomppa




More information about the ecl-devel mailing list