[Haskell-cafe] Re: Can my type be allowed as return type in FFI?

Mauricio briqueabraque at yahoo.com
Thu Dec 11 10:28:04 EST 2008

>> This would  solve half my problem.  Can I always  trust that? I've
>> been told before  that everytime a C function  returns a struct it
>> is actually  returning a pointer, but  I wasn't able  to find that
>> written  in stone
> That's because it isn't true.
> In fact one of the classical ways for a C function to
> return a struct is to be *GIVEN* a pointer, e.g.,
> (...)

Sure, sorry. I should have said that the C functions fill memory
from a given pointer.

> and obviously a C compiler is entitled to return a small struct
> in registers if it feels like it.

If a compiler is compiling code that calls a library, how is it
supposed to know if a return pointer is been passed as a register
or by using a pointer? The compiler may not have access to the
built library to check that. (Begginer question, I never wrote
assembly code.)


More information about the Haskell-Cafe mailing list