[fpc-pascal] Record size

Carsten Bager carsten at beas.dk
Tue May 24 15:54:19 CEST 2011


I have a data record ("sVar_typ") compiled with the 2.2.5 arm compiler. It has the size of 
32728 byte.
Now I try to compile with the 2.4.5 arm compiler it has the size of 32736 byte.

I write the addresses of the variables in the record, they have not changed.
It looks like the compiler just adds 8 byte to the record at the end.
If I use "Packed" in the record, the 8 byte disappears.
Because the record is used in a file, I have to know the size.
Is this an indented behavior of the compiler?

Regards Carsten


  sVar_typ = Record                 
    case Boolean of
      True:(                               
       version:integer32;                  
       PanelStart:Integer32;               
       ops:spOps_typ;                      
       aabLuk:aabLukTid_typ;               
       text:textS_typ;
       MontPgm:mont_Typ;                   
       mdI:mPgmDataFeltI_typ;              
       Pris:Pris_typ;                      
       hh:hh_typ;                          
       pris2tid:pris2tid_typ;              
       SommerTid:SommerTid_typ;            
       TurFdat:TurFdat_typ;                
       TurGdat:TurGdat_typ;                
       Modul:Modul_typ;                    
       MaskinText: array[0..30] of shortString;
       dorGruppe:  array[MinMas..MaxMas] of integer32;
       debug:Debug_typ);                    
     False:(data:packed array[0..8180] of integer32;
     ckSum:integer32);                      
  End;

  Writeln(hexstr(longword(@sVar),8));
  Writeln(hexstr(longword(@sVar.version),8));
  Writeln(hexstr(longword(@sVar.PanelStart),8));
  Writeln(hexstr(longword(@sVar.ops),8));
  Writeln(hexstr(longword(@sVar.aabLuk),8));
  Writeln(hexstr(longword(@sVar.text),8));
  Writeln(hexstr(longword(@sVar.MontPgm),8));
  Writeln(hexstr(longword(@sVar.mdI),8));
  Writeln(hexstr(longword(@sVar.Pris),8));
  Writeln(hexstr(longword(@sVar.hh),8));
  Writeln(hexstr(longword(@sVar.pris2tid),8));
  Writeln(hexstr(longword(@sVar.SommerTid),8));
  Writeln(hexstr(longword(@sVar.TurFdat),8));
  Writeln(hexstr(longword(@sVar.TurGdat),8));
  Writeln(hexstr(longword(@sVar.Modul),8));
  Writeln(hexstr(longword(@sVar.MaskinText),8));
  Writeln(hexstr(longword(@sVar.dorGruppe),8));
  Writeln(hexstr(longword(@sVar.debug),8));
  Writeln(hexstr(longword(@sVar.ckSum),8));
  Writeln(sizeof(sVar_typ));
  

Compiler 2.4.5
000F3694
000F3694
000F3698
000F369C
000F382C
000F38D4
000F57D4
000F5814
000F6014
000F6514
000F6524
000F6604
000F66A4
000F66F8
000F6978
000F69D4
000F88D4
000F8954
000FB668
32736


Compiler 2.2.5
000F3694
000F3694
000F3698
000F369C
000F382C
000F38D4
000F57D4
000F5814
000F6014
000F6514
000F6524
000F6604
000F66A4
000F66F8
000F6978
000F69B8
000F88B8
000F8938
000FB668
32728




More information about the fpc-pascal mailing list