[fpc-devel] Abbrevia and Delphi compatibility

DrDiettrich drdiettrich at compuserve.de
Thu Feb 17 09:52:06 CET 2005

Marco van de Voort wrote:
> > 2) Sets with minimal size, at least with 1 and 2 bytes for replacement
> > of Byte and Word types.
> >
> > I consider both features as vital in translations from C to Pascal, and
> > in the detection and elimination of bugs. Will it be possible to add
> > these features to FPC, this year?
> I'm interested in the last one. What is exactly the problem with it, except
> foreign data, like API declarations (which are rare anyway), and binary
> files?

The size restriction applies almost only to filed records, whereas
in-memory data structures usually can be realigned at will.

The use of enums and sets allows for safer code, instead of working with
bitmasks and general ordinal data types and constants. According (set)
variables can be found in many data structures, so that it would be nice
to retype such fields as appropriate sets in Pascal code.
> The C argument is a bit doubtful, since there are more such problems (like
> bitpacking, not being able to exactly duplicate any union), so 1:1 remapping
> is not really possible anyway.

Even C bitfields can be emulated perfectly in Pascal, with Object types
and properties.
Named C unions can be emulated by variant records in Pascal, only
anonymous unions sometimes require changes to the code, or the use of
objects with properties. But also some (legacy) Pascal constructs (file
open mode...) could be much nicer and safer with structured data types.


More information about the fpc-devel mailing list