Writing portable code regarding the processor architecture

From Lazarus wiki
Revision as of 01:56, 29 December 2003 by FPK (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

There are two main issues when writing code which is portable regarding the processor architecture: endianess and 32 vs. 64 Bit processors.

Endianess

32 Bit vs. 64 Bit

To achive a maximum compatiblity with older code, FPC doesn't change the size of predefined data types like integer, longint or word when changing from 32 to 64 Bit. However, the size of a pointer is 8 bytes on a 64 bit architecture so constructs like longint(pointer(p)) are doomed to crash on 64 bit architectures. However, to allow you to write portable code, the FPC system unit introduces the types PtrInt and PtrUInt which are signed and unsigned integer data types with the same size as a pointer.

Calling conventions