Pointers are not Integers
: It is common for some developers to treat pointers and integers (especially long integers) as having the same size when writing 32-bit code. For example:
unsigned int pVal = (unsigned int)pointerVar;
Code similar to that shown above will not work on a 64-bit operating system, since the value of the 64-bit pointer may be truncated to fit into the 32-bit integer. Whether or not truncation will happen depends on the operating system:
- Windows: long and int remain 32-bit in length, and special new data types are defined for 64-bit integers.
- Linux: long becomes 64-bits in size while int remains 32-bits in size on the 64-bit versions of Linux.