Hi All.
program test;
type t1 = packed record item1 : byte; item2: byte; item3: byte; end; t2 = packed array [0..0] of t1;
begin writeln ('SizeOf (t1): ', SizeOf (t1)); writeln ('SizeOf (t2): ', SizeOf (t2)); readln; end.
Output of program:
SizeOf (t1): 3 SizeOf (t2): 4
Could anybody tell me - why?
Thanks.
software:
gpc version 2.1 (20020510), based on 2.95.3 20010315 (release) Linux RedHat 2.5.52
My guess is that the array elements are being aligned on word boundaries.
Grant
At 9:25 PM +0300 31/1/03, Ingvar Marny wrote:
Hi All.
program test;
type t1 = packed record item1 : byte; item2: byte; item3: byte; end; t2 = packed array [0..0] of t1;
begin writeln ('SizeOf (t1): ', SizeOf (t1)); writeln ('SizeOf (t2): ', SizeOf (t2)); readln; end.
Output of program:
SizeOf (t1): 3 SizeOf (t2): 4
Could anybody tell me - why?
Thanks.
software:
gpc version 2.1 (20020510), based on 2.95.3 20010315 (release) Linux RedHat 2.5.52
Ingvar Marny wrote:
program test;
type t1 = packed record item1 : byte; item2: byte; item3: byte; end; t2 = packed array [0..0] of t1;
begin writeln ('SizeOf (t1): ', SizeOf (t1)); writeln ('SizeOf (t2): ', SizeOf (t2)); readln; end.
Output of program:
SizeOf (t1): 3 SizeOf (t2): 4
Could anybody tell me - why?
Packed arrays are currently accessed in half-word entities (i.e., 16 bits on most systems). This might seem unlogical, but the packing is only done within the array, not outside.
I might change it sometime because it also causes other (small) problems, but it's not trivial to do ...
Frank