[fpc-devel] integer, cardinal
Jonas Maebe
jonas at zeus.ugent.be
Sat Apr 16 21:33:06 CEST 2005
On 16 Apr 2005, at 17:04, Yury B. wrote:
> Why integer is 16-bit in default (FPC) mode?
> It's ok to define it as 16-bit in BP-compatibility mode, but in FPC
> it should be like in delphi - natural to the platform, i.e. 32-bit
> for 32-bit x86... or does 64-bit platform also uses 32-bit integers
> as default, so that longint would be good?
It would break a lot of existing code if we did that. You can perfectly
define integer to be whatever you want yourself. That's also how it's
done in Delphi and objfpc mode: the objpas unit is then automatically
included, and this unit simply includes the following declaration:
type
integer = longint;
Jonas
PS: on most processors, using 16 bit numbers is going to be faster than
using 32 bit numbers, since they occupy less memory and thus leave more
room in the cache for other stuff. Afaik, the x86 family is the only
one which is handicapped when performing 16 bit calculations in 32 bit
mode (and even there, some processors do not have an explicit penalty,
although your code grows slightly because of the prefixes to the
instructions -- but then again, this is compensated when the
instruction includes a constant).
More information about the fpc-devel
mailing list