Xref: news-dnh.mv.net comp.os.msdos.djgpp:1525 Newsgroups: comp.os.msdos.djgpp Path: news-dnh.mv.net!mv!news.sprintlink.net!in1.uu.net!psinntp!psinntp!psinntp!psinntp!netrixgw.netrix.com!news From: ld AT jasmine DOT netrix DOT com (Long Doan) Subject: Re: Packed structs Lines: 27 Sender: news AT netrix DOT com Reply-To: ld AT netrix DOT com Organization: Netrix Corporation References: Date: Mon, 14 Aug 1995 12:22:40 GMT To: djgpp AT sun DOT soe DOT clarkson DOT edu Dj-Gateway: from newsgroup comp.os.msdos.djgpp In article "A.Appleyard" writes: > If I have this struct:- > typedef struct{char miaow; int mice_caught,birds_caught; char*name;} cat; > and it needs to be packed, i.e. the fields starting at bytes 0, 1, 5, 9, and > the whole struct exactly 13 bytes long with no extra bytes inserted to fill > out to a multiple of 2 or 4, should I insert `__attribute__((packed))' after > `cat', or before any `;' where djgpp would otherwise be tempted to insert > filling bytes, or where? Try: typedef struct { char miaow __attribute__ ((packed)); int mice_caught __attribute__ ((packed)); int birds_caught __attribute__ ((packed)); char *name __attribute__ ((packed)); } cat; Hope that helps, Long. -- ============================================================== Long Doan ld AT netrix DOT com Netrix Corporation ldoan1 AT osf1 DOT gmu DOT edu 13595 Dulles Technology Drive Herndon Va 22071 ==============================================================