[Ecls-list] Re: floats and uffi
goffioul at imec.be
Thu Sep 15 00:51:17 UTC 2005
> "Goffioul Michael" <goffioul at imec.be> wrote:
> > 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.
> I don't think that's the problem, object_to_float() is declared in
> one of ecl's header files.
I was not talking about "object_to_float", but about "test". This function
is not declared anywhere, hence the compiler guesses its signature from
the code itself.
> Now I looked at the c source and there's no object_to_float at all:
> Why double? Maybe that explains the data loss.
Indeed, without declaration for "test", the compiler probably assumes
that the signature for "test" is: int test(double). As the actual "test"
argument should be float, the function gets called with an incorrectly
I also confirm that when declaring an argument as :float in a foreign call,
the generated code uses object_to_double instead of object_to_float. But
I don't know why as the coercion code seems to be able to handle both
(in cmpffi.lsp). Juanjo?
More information about the ecl-devel