On 17 Dec 2002 at 2:48, Frank Heckenbach wrote:
[...]
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).
Is the built in "WordBool" always guaranteed to 32 bits?
(LongBool and LongestBool are both 64 bits on IA32,
Hmmm ... I never knew this. I guess one should never assume anything ;)
[...]
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.
Me neither. I would not be surprised if it didn't.
AFAIK, there are GNU C interfaces? Which types do they use?
All sorts of typedefs and macros mapping various things to various other GNU things. It is easier for gcc, since they are dealing with interfaces designed for C programmers.
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.
The real problem (??) with the WinAPI is that it is based almost entirely on DLL exports. Therefore the actual parameters supplied must match the ones expected in size, and the sizes of function results must also match - else the DLL will not know what to do with it, and the program will fail in all sorts of ways. I doubt that the interfaces will ever change completely. What might change (and has changed in the past) are the sizes of various types. So today, with 32-bit Windows, INT is 32 bits. With 64-bit Windows, it might well be 64 bits (I don't know, because I am not a beta tester). This should not cause any problem, as long as one can define INT as 64 bits. Then if INT is 64 bits, DWORD or LONG may well become 128 bits, etc., ad nauseum. Of course, GCC will hopefully keep up, and so any manual solutions in GPC should hopefully be minimal.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Web: http://www.bigfoot.com/~african_chief/