[Mono-list] float p/invoke
Andreas Färber
andreas.faerber at web.de
Thu Nov 9 14:44:46 EST 2006
Hello,
I'm facing a weird marshalling issue...
The Objective-C runtime on OS X exposes a method:
id objc_msgSend(id, SEL, ...); // with id and SEL pointers
I marshal it as IntPtr objc_msgSend(IntPtr, IntPtr, ...) using an SRE
p/invoke method factory.
This has worked fine so far, but now I noticed some marshalling
problems. The method's semantic return value is not always a pointer
but is apparently also used for int, unsigned int - which works fine
through IntPtr casting, but not for float. To my understanding float
is single-precision floating point number, thus 32 bits or 4 bytes
wide and identical to IntPtr.Size in a 32-bit environment. However,
when the method semantically returns a float, via IntPtr marshalling
I always get value 1 whereas return type float gives the correct
value but soon after leads to the app hanging, on both PPC and Intel.
Shouldn't the different managed types only lead to different
interpretations of the original 4 bytes? Am I missing something easy?
Andreas
More information about the Mono-list
mailing list