*_PTR were added to the Windows API to support Win64 64-bit addressing.
Since 32-bit APIs usually pass pointers using data types of the DWORD type, it was necessary to create new types for 64-bit compatibility, which could replace DWORD in 32-bit applications, but were expanded to 64 bits when used in 64-bit applications .
So, for example, application developers who want to write code that works like 32-bit or 64-bit Windows 32bit SetWindowLong(HWND,int,LONG) have been changed to SetWindowLongPtr(HWND,int,LONG_PTR)
In a 32-bit assembly, SetWindowLongPtr is just a macro that allows SetWindowLong , and LONG_PTR also a macro that allows LONG . On the other hand, with the 64-bit layout, SetWindowLongPtr is an API that takes 64 bits as the third parameter, and ULONG_PTR is a typedef for unsigned __int64 .
Using these _PTR types, one code base can be compiled for both Win32 and Win64 purposes.
When performing pointer arithmetic, these types must also be used in 32-bit code, which must be compatible with 64-bit.
so if you need to access an array with more than 4 billion elements, you will need to use INT_PTR, not INT
CHAR* pHuge = new CHAR[0x200000000];
Chris Becke Aug 13 '09 at 14:40 2009-08-13 14:40
source share