{$MODE OBJFPC }
{$MODESWITCH ADVANCEDRECORDS }
{$MODESWITCH TYPEHELPERS }
{$MODESWITCH ALLOWINLINE }
{$MODESWITCH RESULT }
{$MODESWITCH PROPERTIES }
{$MODESWITCH ANSISTRINGS- }
{$MODESWITCH AUTODEREF- }
{$MODESWITCH UNICODESTRINGS- }
{$MODESWITCH POINTERTOPROCVAR- }
{$LONGSTRINGS OFF }
{$WRITEABLECONST ON }
{$TYPEDADDRESS ON }
{$ALIGN ON }
(*
0000 afb0 46 50 43 20 33 2e 30 2e 34 20 5b 32 30 31 37 2f FPC 3.0.4 [2017/
0000 afc0 31 30 2f 30 36 5d 20 66 6f 72 20 78 38 36 5f 36 10/06] for x86_6
0000 afd0 34 20 2d 20 57 69 6e 36 34 00 00 00 00 00 00 00 4 - Win64.......
0000 afe0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000 aff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
// seems to always align on a 16 byte boundary no matter the setting of
// align or packed record
0000 b000 66 69 72 73 74 20 20 63 68 61 72 61 63 74 65 72 first character
0000 b010 20 61 72 72 61 79 00 00 00 00 00 00 00 00 00 00 array..........
0000 b020 73 65 63 6f 6e 64 20 63 68 61 72 61 63 74 65 72 second character
0000 b030 20 61 72 72 61 79 00 00 00 00 00 00 00 00 00 00 array..........
0000 b040 74 68 69 72 64 20 20 63 68 61 72 61 63 74 65 72 third character
0000 b050 20 61 72 72 61 79 00 00 00 00 00 00 00 00 00 00 array..........
0000 b060 66 6f 75 72 74 68 20 63 68 61 72 61 63 74 65 72 fourth character
0000 b070 20 61 72 72 61 79 00 00 00 00 00 00 00 00 00 00 array..........
0000 b080 61 6e 64 20 73 6f 20 6f 6e 00 00 00 00 00 00 00 and so on.......
0000 b090 74 65 78 74 20 69 6e 20 61 20 72 65 63 6f 72 64 text in a record
0000 b0a0 20 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1..............
0000 b0b0 74 65 78 74 20 69 6e 20 61 20 72 65 63 6f 72 64 text in a record
0000 b0c0 20 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2..............
0000 b0d0 74 65 78 74 20 69 6e 20 61 20 72 65 63 6f 72 64 text in a record
0000 b0e0 20 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3..............
0000 b0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000 b100 39 54 68 69 73 20 62 69 6e 61 72 79 20 68 61 73 9This binary has
0000 b110 20 6e 6f 20 73 74 72 69 6e 67 20 63 6f 6e 76 65 no string conve
0000 b120 72 73 69 6f 6e 20 73 75 70 70 6f 72 74 20 63 6f rsion support co
*)
program CharacterArraysAlignment;
const
{$align 1}
s1 = 'first character array';
s2 = 'second character array';
s3 = 'third character array';
s4 = 'fourth character array';
s5 = 'and so on';
p1 : pchar = s1;
p2 : pchar = s2;
p3 : pchar = s3;
p4 : pchar = s4;
p5 : pchar = s5;
l1 = length(s1);
l2 = length(s2);
l3 = length(s3);
l4 = length(s4);
l5 = length(s5);
type
{$align 1}
{$packrecords 1}
tmessages = bitpacked record
const m1 = 'text in a record 1';
const m2 = 'text in a record 2';
const m3 = 'text in a record 3';
end;
var
messages : tmessages;
const
mp1 : pchar = messages.m1;
mp2 : pchar = messages.m2;
mp3 : pchar = messages.m3;
begin
writeln(p1, l1);
writeln(p2, l2);
writeln(p3, l3);
writeln(p4, l4);
writeln(p5, l5);
writeln(mp1);
writeln(mp2);
writeln(mp3);
end.