Prof A Olowofoyeku (The African Chief) wrote:
Because only such a strange type (strange especially if used with Boolean semantics) would warrant using `Boolean (32)' in Pascal.
Not at all. See my other post. You cannot use an 8-bit or 16-bit value when the WinAPI expects an argument (and sometimes, even function results) to be 32-bits in size. Borland's solution is to predefine 8- bit (Boolean and ByteBool), 16-bit (WordBool) and 32-bit (LongBool) boolean types, and then to define BOOL as LongBool, for the WinAPI routines. If GPC can predefine all these, plus things like LongLongBool (64-bit) and LongestBool (128-bit?) then, we can avoid "Boolean (32)". But the problem will still be there when we need to define a data type of a specific size that is not the default size.
Short reality check: GPC already has WordBool etc. (though with 32 bits by default, but you could redefine it as ShortBool, which is in fact better suited than `Boolean (16)' if it's main use it to match `short' in C interfaces).
(LongBool and LongestBool are both 64 bits on IA32, there's no 128 bit type yet, and I don't know if there ever will be on 32 bit platforms (but if GCC will ever have it, so will GPC, of course).)
Prof A Olowofoyeku (The African Chief) wrote:
The long and short of it: for as long as GPC expects to support Windows programmers, there is no way out of being able to declare a 32-bit Boolean type - and when Windows moves to 64-bits, we may well need a 64- bit Boolean type.
Which we have ...
Someone (not Frank) suggested a simple arithmetical expression (e.g., x =/<> 0).
I think I did (but maybe Chuck as well). However, since I don't plan to drop WordBool etc., the only situation where you really couldn't avoid it then would be a Boolean type of strange size (5 or whatever ;-), and quite frankly, if such a strange thing is ever used anywhere seriously (I doubt it), it might justify adding `<> 0' in a few places ...
J. David Bryan wrote:
On 15 Dec 2002 at 3:33, Frank Heckenbach wrote:
Yes, plain integers I suppose, not integers with a specified width of 32 bits.
What is a "plain" integer?
`int'
Is there a guarantee that a "plain" integer in GNU C or Pascal will be the same size as a "plain" integer in Microsoft C (e.g.)?
The guarantee is that it's the same in GPC and GCC. I don't know if MS C guarantees anything.
AFAIK, there are GNU C interfaces? Which types do they use?
The Win32 documentation from Microsoft says explicitly, for example, that an INT (defined in "windef.h" as "typedef int INT") is a "32-bit signed integer," so when interfacing, an INT parameter _must_ be 32 bits.
Is this a library interface or an ABI description? I suppose the latter. E.g., the Chief mentioned 64 bit Windows -- if its ABI has `int' to be 64 bit (I don't know if it does, often on 64 bit systems, `int' is still 32 bit, and `long int' (`Med...' in GPC) is 64 bit), do you really expect the interfaces to change to `short' (or whatever is 32 bit then)? I wouldn't. I'd expect the C types to remain the same, even if the sizes vary. (At least that's what I know from other systems, and which makes porting to 64 bits generally rather easy, just recompiling with a compiler for the new target -- as long as you didn't make any assumptions such as a pointer having the same size as `int' (probably the most common one in C, should be less of a problem in Pascal).)
Or the interfaces change completely (or substantially). In this case, the whole point is moot. Then we're talking about one specific platform without any portability concerns, and any type that has a matching size (i.e., plain int and `long' in C, and `WordBool' and `MedBool' in GPC) will do.
Frank