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
On 2008 Dec 11, at 10:28, Mauricio wrote:
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?
Sorry, I'm not talking about how C implements passing structures to
functions. The Haskell FFI can only bind functions that pass structures
by pointer, not by value. So if you've got a C function that passes them
by value then you need to write a wrapper function in C and bind to
that.
This
foreign import nameOfFunction nameOfFunction
:: IO MyType
Is it possible to write a new MyType and make it allowed as
a return type from foreign functions? Is changing the
compiler the only way to do that?
Of course you're not really returning a MyType but a pointer
On Wed, 2008-12-10 at 14:17 -0200, Mauricio wrote:
foreign import nameOfFunction nameOfFunction
:: IO MyType
Is it possible to write a new MyType and make it allowed as
a return type from foreign functions? Is changing the
compiler the only way to do that?
On 11 Dec 2008, at 5:17 am, Mauricio wrote:
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.