[fpc-pascal] Cache-line alignment for records

Jonas Maebe jonas at freepascal.org
Wed Mar 29 23:07:18 CEST 2023


On 29/03/2023 16:00, Matias Ezequiel Vara Larsen via fpc-pascal wrote:
> So if I have a type like:
> 
> test = record
>    r: DWord;
>    s: Word;
> end;
> 
> Then, I define the variable `nada` as an array of `test` type:
> 
> var
>    nada: array[0..2] of test;
> 
> Is the `@nada[1].r` element aligned to 4-bytes?

Records always get padded to a multiple of their internal alignment 
requirement. Unless you're on a system where the default packrecords 
value is 2 (msdos-i8086 has that probably), the above record's internal 
field alignment is 4 and hence its size will also be padded to a 
multiple of 4.


Jonas


More information about the fpc-pascal mailing list