Next: , Previous: Integer Types with Specified Size, Up: Integer Types



6.2.3.4 Integer Types and Compatibility

If you care about ISO compliance, only use Integer and subranges of Integer.

Some of GPC's non-ISO integer types exist in Borland Pascal, too: Byte, ShortInt, Word, and LongInt. The sizes of these types, however, are not the same as in Borland Pascal. Even for Byte this is not guaranteed (while probable, though).

When designing GNU Pascal, we thought about compatibility to Borland Pascal. Since GNU Pascal is (at least) a 32-bit compiler, Integer must have (at least) 32 bits. But what to do with Word? Same size as Integer (like in BP) or 16 bits (like in BP)? We decided to make Word the “natural-sized” unsigned integer type, thus making it (at least) 32 bits wide. Similarly, we decided to give LongInt twice the size of Integer (like in BP) rather than making it 32 bits wide (like in BP). So LongInt has 64 bits, and ShortInt has 16 bits on the IA32 platform.

On the other hand, to increase compatibility to Borland Pascal and Delphi, GPC provides the alias name Comp for LongInt (64 bits on IA32) and SmallInt for ShortInt (16 bits on IA32). Note that BP treats Comp as a “real” type and allows assignments like MyCompVar := 42.0. Since we don't consider this a feature, GPC does not copy this behaviour.