From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Peeter Joot/Toronto/IBM" To: Silvio Bandeira Cc: gcc Subject: data alignment Date: Wed, 13 Sep 2000 21:24:00 -0000 Message-id: X-SW-Source: 2000-09/msg00300.html > I've used "__attribute__ ((packed))" after defining a struct, but it > decreases portability. Hi Silvio, There is no such thing as "decreases portability" if you are delving into the use of pragma's for packing or using __attribute__((packed)). This is an inherently unportable action, and if you do it you have to face the consequences. In fact it is a really really bad idea in general and will cause exceptions (or real poor performance) on a number of platforms when the unaligned members are accessed. Unless you have a really good reason, just don't do it. Perhaps you can reorder your structure to fix the alignment problems. What specific reason do you need a packed structure? Another options is treating the memory in a raw format and doing bytewise copies in and out of the structure -- that is probably as close to portable you are going to get (if you are careful). Peeter