Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: "Ian Mausolus" , djgpp AT delorie DOT com Date: Wed, 19 Mar 1997 17:18:53 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: packed structures "Ian Mausolus" wrote: > Can someone please tell me what the following satements do and how to use > them? As well, what is the difference between them? > > 1) #pragma pack(...) > 2) __attribute__((packed)) > GCC alignes all the data so the members of an struct are aligned to 32 bits boundaries. For example struct { char a; int b; } foo; will use 8 bytes of memory, a will be in the offset 0 and b in the offset 4, but if you use the packed attribute b will be at offset 1 (be carreful foo will still using 8 bytes). Under plain C the attribute is enough but under C++ there are a bug in the C++ front-end and you need to enclose the declaration with the above pragma. SET --------------- 0 -------------------------------- Salvador Eduardo Tropea (SET). Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013