[fpc-pascal]Re: Incompatible record alignment?

Peter Vreman peter at freepascal.org
Fri Jan 11 12:02:02 CET 2002


> 
> > >
> > > 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.







More information about the fpc-pascal mailing list