The model has LP64 , which means that pointers are also long 64-bit; This is the standard for AMD64 on Linux and many other platforms; the other is Windows LLP64 , where only long long is 64 bits wide and long is 32 bits wide.
Common choice: char is the smallest addressable unit and preferably 8 bits. sizeof(short) at least 2; if the processor supports this, then so be it. int usually chosen as the fastest integer type - on the AMD64 architecture in 64-bit mode, 32-bit registers are faster or more supported than 16 or 64-bit registers (for 16 and 64-bit registers, a byte prefix is โโrequired).
Now, the reason Windows uses LLP64 is because compatibility - a lot of code made the wrong assumption that long is 32 bits; similarly in the Unix world, it is assumed that the pointer matches long - now that the pointers are 64-bit, then long should match that width.
To write portable programs, include <inttypes.h> and use constants there; otherwise, suppose these types have their minimum size (int 2 bytes, etc.). Use intptr_t / uintptr_t for integer variables that also need to be wide enough to hold a pointer, or use a union.
source share