Fri, 27 Jul 2001 11:21:52 +1000
Sam Ruby wrote:
> Rhys Weatherley wrote:
> > [DllImport("libc")]
> > extern unsafe public static int_t stat(string pathname, stat *buf);
> Very nice proposal. Would the following also work?
> extern public static int_t stat(string pathname, out stat buf);
Not necessarily. This assumes that the VM uses the same
representation for managed and unmanaged pointers. Some
VM's may use object handles for managed pointers, and
real C pointers for unmanaged pointers. These values aren't
always going to be bit-for-bit compatible.
I'd rather not introduce a dependency that requires managed
and unmanaged pointers to have an identical representation.
It is theoretically possible that the PInvoke mechanism could
automatically convert managed to unmanaged. But I'm wary
of that, because then how do I pass managed pointers to
a native method that actually knows about them?