From: Michel <dae...@st...> - 2000-06-28 08:18:17
|
Giorgio, you sent the post to the -admin address (bascially to Sven and me :) Michel -------- Original Message -------- Subject: struct Node offsets Problem fixed (i think) Date: Tue, 27 Jun 2000 19:49:12 +0200 From: Giorgio Terzi <de...@ip...> To: lin...@li...,Nicholai Benalal <nic...@ch...> Hello all, (because of alignments ;-) please read this e-mail with something like a plain editor, with fixed width font, thanks). As you know i have found an alignment problem in offset calculation of the Node structure when interfacing with existing AmigaDos code. Simply gcc assumes to even align the structure members, so bytes grow to be shorts and structure effective offsets CHANGE!!! If we create something of new there is not problem, but if we try to read something in system created structures (struct Node for example) we will find crashes or at better exceptions. I think that the solution is this: struct Node offsets { packed not packed struct Node *ln_Succ; 0 0 struct Node *ln_Pred; 4 4 UBYTE ln_Type; 8 8 BYTE ln_Pri; 9 a char *ln_Name; a c } __attribute__ ((aligned (2), packed)); i have added in the tail of the struct Node declaration the __attribute__ keyword with the aligning parameters you see in the above example in the Node.h header file. As the docs say this "packs" the structure and word align it. It works! But if someone has other ideas or solutions is welcome because i do not think to know gcc options so well to be mathematically sure that this is the only way to solve the problem. Kind regards -- Giorgio Terzi |