[fpc-pascal] History of the Cardinal data type?

Nikolay Nikolov nickysn at gmail.com
Tue Mar 29 22:55:21 CEST 2016

On 03/29/2016 06:13 PM, Marco van de Voort wrote:
> In our previous episode, Graeme Geldenhuys said:
>> Just curious. What is the history behind the Cardinal data type. As per
>> the FPC documentation, it is always mapped to the LongWord type. I
>> presume it is the same in Delphi.
> Cardinal is the Wirthian designation for the default unsigned integer,
> just like "integer" is for signed.
> The Delphi side of things is more convoluted because pre-int64 Delphis had
> 31-bits Cardinals.
Even more so, Delphi 1 was 16-bit and its Cardinal type was 16-bit (i.e. 
equal to the "Word" type) With Delphi 2 (the first 32-bit Delphi), 
Cardinal became 32-bit (31-bit, actually, as Marco said).

So, back then it was a CPU-specific unsigned integer type (just like 
"Integer" is the signed version).

Note that even though FPC now also supports 16-bit x86 CPUs, Cardinal is 
still 32-bit unsigned there. Even though this is not Delphi 1 
compatible, changing Cardinal to 16-bit does more harm that good. Many 
FPC demos, such as fpctris and samegame now run unmodified on 
i8086-msdos. If we changed the Cardinal type to 16-bit, they would break 
and require changes in order to work. And most 16-bit code that is 
likely to be ported to FPC is coming from Turbo Pascal, which didn't 
have Cardinal (only "Word", which is always 16-bit), so we don't really 
follow the convention that Cardinal is a platform specific type. So, in 
FPC it is fixed to 32-bit unsigned on all platforms and in all compiler 


More information about the fpc-pascal mailing list