The keyword __ptr32 is a qualifier that can be applied to a pointer type to constrain its size to 32 bits. This language extension is provided to facilitate porting structures with pointer members from 31- to 64-bit mode. The qualifier is accepted and ignored in 31-bit mode.
The size of a pointer type doubles to 64 bits in 64-bit mode. Doubling the size of a pointer changes the layout of a structure that contains pointer members. If the object referenced by a pointer member resides within a 31-bit addressing space, constraining the pointer to 32 bits can reduce some of the unexpected effects of moving to 64-bit mode.
int * __ptr32 p;
declares p to
be a 32-bit pointer to int. int * __ptr32 *q;
declares q to
be a 64-bit pointer to a 32-bit pointer to int. int * __ptr32 const r;
declares r to
be a const 32-bit pointer. Pointers with external linkage must be __ptr32-qualified consistently across all compilation units. If a pointer is declared 31-bit in one compilation unit and 64-bit in another, the behavior is undefined.
Assignment of 32-bit and 64-bit pointers to each other is permitted. The compiler generates an implicit conversion or truncates without emitting a diagnostic.