[fpc-pascal] Re: Data alignment of records

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Dec 10 13:28:35 CET 2010

On 10 Dec 2010, at 13:08, Luis Fernando Del Aguila Mejía wrote:

> Can someone explain to me, about the Data alignment of  records and  
> other variables.

The alignment of records (and TP-style objects) is the same as  
alignment of its fields with the highest alignment requirement. For  
base types (integers, floating point types, pointers), the alignment  
depends on the target operating system. For Mac OS X and non-i386  
systems, we follow the official ABI (application binary interface) of  
every system.

For i386-platforms other than Mac OS X, I guess we follow Delphi. I'm  
not sure whether these rules are documented anywhere, and they were  
probably implemented based on writing test programs.

Maybe a better question is: why do you want to know the alignment of  
different data types? Since it can change depending on which platform  
you are compiling for, writing your code assuming a particular  
alignment is generally a very bad idea.


More information about the fpc-pascal mailing list