[fpc-pascal] Records

Adriaan van Os fpc at microbizz.nl
Wed Oct 26 11:38:52 CEST 2005


Jonas Maebe wrote:

> Micha Nelissen wrote:
>
>>> Because you can't simply compare the memory ranges occupied by 
>>> records A and B. They could have different pad bytes (and bits) but 
>>> still be the same.
>>
>> Isn't the number of pad bytes a property of a type ? So when two vars 
>> are of the same type, they also have the same number of pad bytes ?
>
> Yes, but two different variables of the same type could have different 
> values for those pad bytes. So you have to compare everything but the 
> pad bytes.

Yes, consider

	type myRec = record b: boolean; l: longint end;

Dependent on the alignment (and packing) mode there can be 0, 1 or 3 
pad bytes between the two fields.

By the way, in a similar thread about this subject for gpc 
(<http://www.gnu-pascal.de/crystal/gpc/en/thread12594.html>) a perl 
script was posted 
(<http://www.gnu-pascal.de/crystal/gpc/en/mail12604.html>) that 
automatically creates comparison operators for record types. I haven't 
checked if it works with fpc.

Regards,

Adriaan van Os




More information about the fpc-pascal mailing list