Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Avoiding Polymorphism

The new data types include two polymorphic types, INT_PTR and LONG_PTR. On 32-bit Windows, the INT_PTR maps to int and the LONG_PTR maps to long. On 64-bit Windows, both types map to the __int64 intrinsic type. The MIDL compiler supports these types for remote procedure calls, but there is an inherent limitation that you must keep in mind when using them in a distributed environment. Be sure to comment your code accordingly.

Regardless of the platform size, the wire size of these polymorphic types is always 32 bits. When unmarshaling on 64-bit Windows, the run-time library sign extends signed values and assigns zero to the high-order bytes for an unsigned value. When putting a 64-bit value on the wire, the run time truncates the high-order bytes. Thus, only the low-order 32-bit values are usable.

Use the polymorphic types only when necessary for porting. For new interfaces, use the MIDL intrinsic integer types __int32 and __int64, or use a pointer type or context handle, whichever is most appropriate for the kind of data being transferred.

The 64-bit compiler supports a new polymorphic intrinsic __int3264. Again, this type was developed to support porting efforts, in this case to support the UINT_PTR types transparently. (Another intrinsic, __long3264, will support the ULONG_PTR type.) Do not use __int3264 directly; use the INT_PTR type when you need a polymorphic type for porting reasons.

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.