One important platform feature, to be considered when writing portable 64-bit code is if it is LP64, LLP64 or ILP64. Those abbreviations stands for size in bits of basic C data types
(
int
, long
, void*
, long long
):Type | ILP64 | LP64 | LLP64 |
int | 64 | 32 | 32 |
long | 64 | 64 | 32 |
pointer | 64 | 64 | 64 |
long long | 64 | 64 | 64 |
Win64 is a LLP64 platform, while Solaris and Linux are LP64 platforms.
Thus the only safe way to store pointers in integer types is either always use uintptr_t
(defined in stdint.h
not included at least with MSVC2003 and earlier), or always
use long long
fields.