I have been following the "cannot take address of packed record" thread and now I have a similar problem.
I perfectly understand that doing a strcopy is an implicit conversion, but I think that the program gets carried away during checks :-)
I had a VERY complex data structure and it took me quite a while to reduce it to the minimum, please bear with me if it's anyway a bit intricate.
let's have the following definitions:
type
char_arr = array[1..30] of char;
smallrec = RECORD arr : char_arr; END;
largerec = packed RECORD one_rec : smallrec; many_rec : array[1..5] of smallrec; one_array : char_arr; many_arrays : array[1..5] of char_arr; END;
VAR r:largerec; c:char_arr;
The largerec record is packed, and contains an assortment of structures.
A lot of assignments are allowed, like:
r.one_array :=c; r.one_rec.arr :=c; r.many_arrays[1] :=c;
This single one is not allowed: r.many_rec[1].arr:=c;
BTW, assigning a single char is allowed: r.many_rec[1].arr[1]:=#0;
So I guess it must be a check that deals with implicits type conversions.
but:
1) I am not converting strings, I am assigning a char_arr to another char_arr 2) if the "r.one_rec.arr :=c" assignment is allowed, I cannot see how the "r.many_rec[1].arr:=c;" can be more "dangerous" in addressing mode.
I am not trying to be fussy just for the fun of it, but my structure is (as life goes :-) just the single variant that will not work.
I am porting an old source code to gpc, while keeping the data file compatibility, so I will explore the unpack-access-pack solution, (hoping that it will not degrade performances too much)
BTW (and here I go into newbie mode) how can I check if there is after all any physical difference between a packed and an un-packed record? Is there something like a length() to measure a record's size in memory??
Also, do I understand correctly that the proposed solution:
{$pack-struct, maximum-field-alignment 8} foo = record sig : array [ 0..3 ] OF Char; end; {$no-pack-struct, maximum-field-alignment 0}
would change the structure of a "file of foo" ?
Thanks! Francesco Bonomi
Francesco Bonomi Si.lab s.r.l. Via Citille 13 50022 Greve in Chianti FI- Italy
Tel +39 - 055 8544805 Fax +39 - 055 8547418
http//:www.silab.it