Waldek Hebisch wrote:
The manual promises that `Integer' is the same size as C `int'. AFAIK on most 64-bit machines `int' is 32 bit. The consequences of C brain damage are rather unpleasent: -- all use of 64 bit integers became non-standard -- string length is limited to 32 bits
I'm not sure if the standard requires it to be limited to `Integer' (of course, that's a bit difficult to decide, since the standard doesn't have any bigger types). But even if we could change it (without changing `Integer'), I don't think it would be worth it, since it's only a small part of the problem.
-- spurious overflows/truncations since procision by default is limited to 32 bits
Of course only if one relies on `Integer' being 64 bits, or `Integer' being able to hold a `Pointer' value. Both are things one shouldn't do anyway.
But I agree that it's not nice -- especially if 32 bit operations are less inefficient, but also otherwise.
On the other hand correcting the problem would break backwards compatibility. Simplest correction would be to say that Pascal `Integer' is equvalent to C `long'. Since on most 32-bit machines both `int' and `long' are 32 bits such a change would not affect popular systems 32-bit systems. Note that currently most m68k systems use 16-bit integers and change to 32 bits would correct many problems.
However, making `Integer' the same as C `long' also has drawbacks: -- 8 and 16 bit processors have 32-bit longs, which may be too large as default size
Does the backend support any 8 or 16 bit platform now?
-- AFAIK Microsoft decided to use 32-bit `long' on 64-bit processors (they wont to use `long long' as 64-bit type).
Even more BD. (Reminds me a bit of Borland keeping `Integer' 16 bits on 32 bit Delphi. BTW, have they finally changed it in newer versions?)
Alternatively, we can exlude Pascal `Integer' from compatibility rules and choose good size in the front end. Or we can make `Integer' the same size as C `size_t'.
That's `SizeType' for us.
I think that main question is if we are willing to break backwards compatibility. Since change in `Integer' size is quite serious difference we can not do this lightly.
It may be too late for a change, I'm not sure ...
As I said, I see the main problems in C interfaces (which so far rely on `Integer = int', while most other places really should not really on exact type sizes etc.). So *if* we change it, we should only change one type, something like `Integer = "undefined" in C', and `CInteger' (or whatever) = `int', so C interfaces would only have to s/Integer/CInteger/g. (And similar for `Cardinal'/`Word', even if nonstandard, but so we keep the fact that `Integer' and `Cardinal' have the same size.)
Of course, we'd also need a transition period here -- add `CInteger' now, let everyone change their interfaces (using GPC-version conditionals to avoid breaking compatibility with older GPCs), sometime change `Integer'. Unpleasant indeed ...
Frank