[Ecls-list] floats and uffi

Goffioul Michael goffioul at imec.be
Wed Sep 14 00:53:11 UTC 2005


ECL doesn't actually load symbols from lib.so dynamically, but requires
a compilation step to achieve this. In the C code generated for test.lisp,
the LISP "test" function is turned into a C-call of the "test" function
from lib.so, however, as there's no header declaring the signature of this
function, I assume that the compiler generates a different signature that it
acutally is in the shared library.

To be clearer, what you will see in the generated C code (you can see it by
adding :c-file t as flags to the compile-file function) is something like:

	test(object_to_float(V1));

As this test function is not declared in some header, the compiler will
automatically guess its signature, and maybe the guess is wrong (at least
in the return type, the compiler assuming int return by default, I think).
This might be the problem.

Michael.

> Hi,
> 
> I have a problem with ecl's uffi. The float value gets corrupted:
> 
> --- lib.c
>   #include <stdio.h>
>   
>   void test (float x) { fprintf(stderr, "%f\n", x); }
>   
> --- test.lisp
>   (uffi:load-foreign-library "./lib.so")
>   
>   (uffi:def-function "test"
>       ((a :float))
>     :returning :void)
>     
>   (test 12.3)
>   
> ---
> 
>   % gcc -shared -fPIC lib.c -o lib.so
>   
>   ecl> (compile-file "test.lisp" :system-p t)
>   ecl> (c:build-program "prog" :lisp-files '("test"))
>   
>   % ./prog
>   -0.000000   
>   
> I tried the current CVS version.
> Is this my fault or is this a bug?
> 
> Thank you.
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development 
> Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * 
> Testing & QA
> Security * Process Improvement & Measurement * 
http://www.sqe.com/bsce5sf
_______________________________________________
Ecls-list mailing list
Ecls-list at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list




More information about the ecl-devel mailing list