From: "A.Appleyard" Organization: Materials Science Centre To: djgpp AT delorie DOT com Date: Wed, 26 Feb 1997 17:00:52 GMT Subject: Re: C++ packed structs.. Message-ID: <36629024DD7@fs2.mt.umist.ac.uk> Olav Kindt wrote:- > ... The faq says that a struct like > struct {char name[7]; unsigned long offset; double quality; > } __attribute__ ((packed)); > will be packed correctly when compiled as C-source. Then it says that > C++ doesn't allow this, and you must declare each struct field with the > packed attribute. Does this in effect mean this : > struct { > char name[7] __attribute__ ((packed)); > unsigned long offset __attribute__ ((packed)); > double quality __attribute__ ((packed)); }; I don't trust the compiler. Best put the `packed' in explicitly before every `;' inside the { }. Better, save a bit of program size, thus:- #define pk __attribute__ ((packed)) > struct {char name[7] pk; > unsigned long offset pk; > double quality pk; };