[Mono-list] passing and returning structs in native calls
Edd Barrett
vext01 at gmail.com
Fri Jan 7 12:12:21 EST 2011
On Fri, Jan 07, 2011 at 04:55:22PM +0100, Robert Jordan wrote:
> On 07.01.2011 16:19, Edd Barrett wrote:
> > Why is this? Myself and a colleague have spent a number of hours trying
> > to work this out.
>
> Because returning structs by value from functions is problematic
> in general. Try to stay away from such signatures if you want
> portability.
Hrm, so I can:
a) pass a pointer.
b) pass the integer alone
>
> > Changing the function to return the integer within the struct instead of
> > the struct itself works as expected, but that is not really what I want.
> >
> > I am using an amd64 machine on OpenBSD (which uses fastcall by default,
> > is this the issue? I know microsoft mono does not support fastcall.
> > Having said that, openbsd has working packages of gtk#, for example.)
>
> GTK avoids returning structs by value.
Clever people.
> > Or perhaps this is a mono bug... I'm completely stuck at this point.
>
> Maybe. IIRC, Mono on amd64 doesn't handle correctly structs of
> sizeof < 8 as return values.
Ouch, if that is correct, that is a nasty bug.
Thanks for the help.
--
Best Regards
Edd Barrett
http://www.theunixzoo.co.uk
More information about the Mono-list
mailing list