[Mono-list] PInvoke Conventions

Tomas Restrepo tomasr@mvps.org
Wed, 18 Jul 2001 11:57:15 -0500

Hi Jay,

> Rhys mentions that Windows does not have this problem because the sizes of
> parameters will stay the same on a 64-bit version of Windows, but I don't
> really believe that.  32-bit Windows changed the sizes of everything from
> to 32 bits, my bet would be that 64-bit Windows will make similar changes
> (by upping the definition of WORD and DWORD).

Not true. There are very specific cases in which type sizes will change, but
they are MUCH fewer than expected, and instead new types have been defined
were appropriate. For example, LONG will still be defined as a 32-bit
integral type, even in Win64 (and that works out fine since the VC++ folks
decided to keep long 32-bit, too).

However, notice that the recent Platform SDKs have introduced one new
#define, called ULONG_PTR which is an integral type that can contain the
value of a pointer for the platform it was compiled in, so it maps to 32-bit
when compiled for Win32, and to 64-bit whjen compiled for Win64.

AFAIK, MS' .NET runtime will be aware of these issues, and will correctly
marshal an IntPtr to the correct value on each of the two platforms, but
unless someone here has had access to the 64-bit CLR version, it's kinda
hard to confirm...

Tomas Restrepo