At 20:39 +0400 28/5/03, Ingvar Marny wrote:
Hi, dear All. I have made exhaustive (at least, hope so) search in the documentation and mail list archives but found only that "GPC will align variables according to maximum performance", but how exactly? On what boundary will be aligned Integer, Boolean, Longint, Word, etc. On what boundary will be aligned string, record, array, their elements and are there any differences between default alignment of variable without record and variable as record field? And, if possible, I need information for the other platforms. I understand that I can make experiments to find it out but it seems to me it should appear in one or in other place (GPS manuals or mailing lists).
I do not think anyone can really give you a definitive answer on this. It depends on the platform as to what the alignment will be, not to mention whether the record is packed or not, and what the $maximum-field-alignment compiler directive is set to, and probably the version of gpc and/or gcc as well.
Typically in GPC, everything is byte aligned unless it has to not be because of the architecture. If you set $maximum-field-alignment to 16 as we do for Mac OS, then everything two bytes or bigger is aligned to two bytes.
The only way to be reasonably reliable is to use a packed record and ensure that the sum of all the sizes of items before any given entry is a multiple of the size of that entry.
GPC doesn't even guarantee what the size of Integer or LongInt or Word is a far as I know, unless you use the size attribute.
Why do you need to know this?
Enjoy, Peter.