However for delphi xe7 (not sure when it was implemented) there's a little documented keyword to choose memory alignment of global variables
Any link to its documentation?
like so:
type
record_align8=record
a,b,c:longint;
end align 8;
The example you gave is to declare a type not a variable. Would adding "align 8" align the elements of the record, or global variables of type record_align8?
The effect of that keyword is that global variables of that type will be aligned on memory boundaries that are multiples of the specified value. For example:
type
record_align8=record
a,b,c:longint;
end align 8;
record_align16=record
a,b,c:longint;
end align 16;
var
aligned8:record_align8; // this global variable will be aligned to memory addresses ending in $0 or $8 only
aligned16:record_align16; // this global variable will be aligned to memory addresses ending in $0 only
This won't cause this type if used as a record field to be aligned like with the {$align} directive though.
As for official documentation I can't seem to find any right now, perhaps it is not documented yet? Dunno how I found out about it then, but I've been using it for a couple months to properly align constants used by SSE code.
But regardless of what delphi does, I'd like to go back to the subject of this thread and find out what the rules of global variable alignment for win32 are in free pascal since they don't seem to match the documentation listed in the first post. For now it appears to be that all global variables are always aligned to 16byte memory boundaries on win32 target.
edit: here's a link where an example is shown (in the second answer):
http://stackoverflow.com/questions/8460862/what-does-packed-now-forces-byte-alignment-of-records-mean . So it seems it's been supported since delphi xe2.