[fpc-pascal] Platform Dependent Integer Types

Florian Klämpfl florian at freepascal.org
Sat Apr 8 21:08:55 CEST 2017

Am 07.04.2017 um 16:15 schrieb Marco van de Voort:
> In our previous episode, African Wild Dog said:
>> Which integer types have their size dependent on platform?
>> E.g. in Delphi, LongInt can 32 or 64 bits depending on the platform.
> In Delphi they retroactively equated longint to C long, being 32-bit on
> 64-bits windows and 64-bit on Linux. The Delphi Linux compiler is btw a
> different compiler than windows.
> On FPC it is always 32-bit. Ptrint and ptruint scale with pointer size, and
> integer depends on compilation mode, 16 or 32-bit.
> For the C compiler that FPC corresponds with (usually gcc), there are types
> that correspond with C types in unit ctypes.
> Maybe some of the new ultra small targets like AVR make exceptions, 

No. The only difference is that the smallest integer operation is 8 bit: On a 32 bit target,
<byte>*<byte> is evaluated as a longint, on avr, it is evaluated as 8 bit operation.

However, we introduced ALUSInt/ALUUInt, it is an int type which scales with the ALU size of the CPU
as PtrInt/PtrUInt are larger than the ALU on AVR.

> but
> those are the general rules.

More information about the fpc-pascal mailing list