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
32-bit unsigned integer
64-bit unsigned integer
32-bit signed integer
64-bit signed integer
32-bit signed integer
64-bit signed integer
Unsigned INT32
Unsigned INT64
Unsigned LONG32
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
Unsigned long type for pointer precision.
Half the size of a pointer. Use within a structure that contains a pointer and two small fields.
Signed integer type for pointer precision.
Signed long type for pointer precision.
The maximum number of bytes to which a pointer can refer. Use for a count that must span the full range of a pointer.
Signed SIZE_T.
Unsigned HALF_PTR.
Unsigned INT_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
A 32-bit pointer. On 32-bit Windows, this is a native pointer. On 64-bit Windows, this is a truncated 64-bit pointer.
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.