According to Frank Heckenbach:
Cardinal 0 .. 65535 Non sign=E9, 16 bits
Cardinal 0 .. 2147483647 Non sign=E9, 32 bits
[...]
That's fine! If Delphi uses "Cardinal", gpc should use it too, of course.
It already does. 32 bits, unsigned. As you can see above, `Cardinal' is 31 bits, unsigned, in Delphiy. Has anybody an idea, why?
Generic Types
GPC's current setting - on *all* platforms - is the following:
GNU Pascal GNU C
Byte unsigned char ByteInt signed char ShortWord unsigned short ShortInt short Integer int, long Word, Cardinal unsigned, unsigned long LongInt, Comp long long LongWord unsigned long long
I see only one possible reason why we should change that: It is not absolutely sure that `int' will always remain the same as `long' on GCC.
The sizes of these types are the same on all platforms I have seen so far. (8, 8, 16, 16, 32, 32, 64, 64.) However I agree that it is a good idea to provide types of known size.
Well defined types
int8 card8 (=3Dbyte is the only case without doubt) int16 card16 int32 card32
[...]
Sounds good.
I agree, but maybe a different syntax would be preferable. UCSD Pascal has a "long Integer" type which is written as
Type Int42 = Integer [ 42 ];
Where `42' is the number of decimal digits. (In the long run, this should be in GPC, too.) What about defining
Type Int16 = Integer ( 16 ); Type Word16 = Word ( 64 );
for types with a specified number of *dual* digits, read: bits?
...
=== BUT ===
What are we talking about?
Pascal has subrange types. Why not forget about all this and let the user specify the types by himself?
Type I16 = -$8000..$7FFF; W16 = 0..$FFFF;
MyRecordToAccessSomeStrangeSystemData = record Descriptor: 0..$FFFFFFFF; ImportantData: -$80..$7F; FillSpace: array [ 0..42 ] of 0..$FF; end (* MyRecordToAccessSomeStrangeSystemData *);
Then, of course, GPC must not reserve more space than necessary for them - which it does not do anyway since it has packed records. (These topics are related, as you can well imagine.)
Compatibility types
anything contained in bpcompat.pas delphi1compat.pas delphi2compat.pas and everything you need, better than compiler switches when possible to avoid to garble the compiler by a lot of special purpose oddities: the idea of C to keep a minimum in the compiler and a maximum in libraries is not so bad (when it is possible).
I agree! Except for "integer", all types can be redeclared in these units. (I think, "integer" could be redeclared, too, but AFAIR it's not a good idea to do so, is it?)
It's not a good idea for the same reason as it is not a good idea to change the size of `Integer' by a compiler switch.
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201] maintainer GNU Pascal [970510] - http://home.pages.de/~gnu-pascal/ [970125]