[fpc-devel] data alignment and int64 (or qword, maybe any singlepiece of size 8 if any)

Пётр Косаревский ppkk at mail.ru
Tue May 16 12:17:56 CEST 2006


> > {$PACKRECORDS n} has almost nothing to do with this inconsistency.
> 
> It does, since the member alignment is defined by {$packrecords n}

> You shouldn't get big gaps them between different variables if you  
> specify a small alignment. You may get them between different record  
> members if you don't change the packrecords setting as well.

I meant, that global variables are 16 bytes aligned by default.
FPC 2.0.3, i386, win32. Even with -Cp386.

{$A-}
type
  a= record
     a: int64;
     b: byte;
     end;

var
  x: a;
  y: byte;
  yy: longword; // 3 bytes gap
  zz: longword; // 9 bytes gap. it's not much, but it's more than one third of user variables space (rtl not counted)
  z: a;

begin
writeln(sizeof(a));
writeln(longint(@x));
writeln(longint(@y));
writeln(longint(@z));
end.



More information about the fpc-devel mailing list