[fpc-devel] Aligned dynamic arrays

Ryan Joseph ryan at thealchemistguild.com
Sat Mar 30 14:59:13 CET 2019



> On Mar 30, 2019, at 9:10 AM, Jonas Maebe <jonas at freepascal.org> wrote:
> 
> FPC always aligns data to its alignment as specified by the platform ABI. {$align x} can be used to limit this alignment to a lower number. It cannot be used to increase it.

This caused us quite a bit of problems with the Metal framework because we needed padding fields also. Is this something that could be added or would it be a disaster to add padding to record fields? It sounds like there is already a mechanism we could extend but I’m not sure.

> 
>> Why not use a similar directive for array alignment? That would solve the problem I discovered with insert/concat.
>> {$push}
>> {$align-array 4096}
>> type
>>   TIntArray = array of integer;
>> {$pop}
> 
> Arrays are aligned to the alignment requirements of their components. Again, a vector type would solve this, since vectors have their own alignment requirements in the ABIs.

If you saw the original bug report we’re trying to make a custom alignment (of 4k) for the Metal framework. I propose the syntax because it solves the problem of how to assign alignment and there is a precedent for it (i.e. $align).

Can you give some examples of the vector type? I don’t exactly know what you guys are referring to.

Regards,
	Ryan Joseph




More information about the fpc-devel mailing list