[fpc-pascal]Re: Incompatible record alignment?

Michael Van Canneyt michael.vancanneyt at wisa.be
Fri Jan 11 12:19:11 CET 2002


On Fri, 11 Jan 2002, Peter Vreman wrote:

> >
> > > >
> > > > Hello all,
> > > >
> > > > I encounter some difficulties when passing a record variable from
> > > > a FPC dynamic link library to a Delphi host program.
> > > > I try to align the record structure on 8-bit boundary for Delphi
> > > > compatibility, but it does'nt work properly. Do I make mistakes here?
> > > > You can test this with the following two little programs:
> > >
> > >
> > > packrecords takes the argument in bytes, not bits.
> >
> > Ok, it was my typo error! I mean 8-bytes boundary alignment,
> > of course.
> > So, for the structure
> >
> > 	{$PACKRECORDS 8}
> > 	type TPoint = record
> >         	       x,y: extended;
> > 	              end;
> >
> > the function SizeOf(TPoint) reports 32 bytes in FPC, since in
> > Delphi it reports 24 bytes (with the same 8-bytes alignment).
> > It seems for me that we have an incompatible records alignment
> > between these compilers.
> > Am I correct here?
>
> extended is 12 bytes, the next 8 byte boundary is 16 bytes. Having that twice gives 32
> bytes. So FPC does it correct. But Delphi calculates the alignment different and doesn't
> correspond with the 8 byte boundary as you asked for.

Normally, doing a {$PACKRECORDS 4} or even 1 would give the same result
as Delphi. The alignment in delphi is normally 2 bytes.

Michael.





More information about the fpc-pascal mailing list