The New Data Types

Three classes of data types were introduced for 64-bit Windows: fixed-precision data types, pointer-precision types, and specific-pointer-precision types. These types were added to the development environment to allow developers to prepare for 64-bit Windows. These types are derived from the basic C-language integer and long types. Therefore, you can use these data types in code that you compile and test on 32-bit Windows, and then recompile with the 64-bit compiler when targeting 64-bit Windows.

Even for applications that target only 32-bit Windows, adopting these new data types makes your code more robust. To use these data types, you must scan your code for potentially unsafe pointer usage, polymorphism, and data definitions. For example, when a variable is of type ULONG_PTR, it is clear that it will be used for casting pointers for arithmetic operations or polymorphism. It is not possible to indicate such usage directly by using the older data types. (You can do this indirectly by using derived type naming or Hungarian notation, but both techniques are prone to errors.)

All of these data types are declared in BaseTsd.h. For more information, including definitions of these data types, see Windows Data Types.

Fixed Precision

Fixed-precision data types are the same length in both 32- and 64-bit Windows. To help you remember this, their precision is part of the name of the data type. The following are the fixed-precision data types.

Term Description
DWORD32
32-bit unsigned integer
DWORD64
64-bit unsigned integer
INT32
32-bit signed integer
INT64
64-bit signed integer
LONG32
32-bit signed integer
LONG64
64-bit signed integer
UINT32
Unsigned INT32
UINT64
Unsigned INT64
ULONG32
Unsigned LONG32
ULONG64
Unsigned LONG64

Pointer Precision

As the pointer precision changes (that is, as it becomes 32 bits on 32-bit Windows and 64 bits with 64-bit Windows), the pointer precision data types reflect the precision accordingly. Therefore, it is safe to cast a pointer to one of these types when performing pointer arithmetic; if the pointer precision is 64 bits, the type is 64 bits. The count types also reflect the maximum size to which a pointer can refer. The following are the pointer-precision and count types.

Term Description
DWORD_PTR
Unsigned long type for pointer precision.
HALF_PTR
Half the size of a pointer. Use within a structure that contains a pointer and two small fields.
INT_PTR
Signed integer type for pointer precision.
LONG_PTR
Signed long type for pointer precision.
SIZE_T
The maximum number of bytes to which a pointer can refer. Use for a count that must span the full range of a pointer.
SSIZE_T
Signed SIZE_T.
UHALF_PTR
Unsigned HALF_PTR.
UINT_PTR
Unsigned INT_PTR.
ULONG_PTR
Unsigned LONG_PTR.

Specific Pointer-Precision Types

The following new pointer types explicitly size the pointer. Be cautious when using pointers in 64-bit code: If you declare the pointer using a 32-bit type, the operating system creates the pointer by truncating a 64-bit pointer. (All pointers are 64 bits on 64-bit Windows.)

Term Description
POINTER_32
A 32-bit pointer. On 32-bit Windows, this is a native pointer. On 64-bit Windows, this is a truncated 64-bit pointer.
POINTER_64
A 64-bit pointer. On 64-bit Windows, this is a native pointer. On 32-bit Windows, this is a sign-extended 32-bit pointer.
Note that it is not safe to assume the state of the high pointer bit.