Date: Tue, 9 Mar 1999 12:21:59 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Rich Dawe cc: djgpp AT delorie DOT com Subject: Re: Real stupid problem. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 8 Mar 1999, Rich Dawe wrote: > : struct SXM_Pat_header { > : int pat_size __attribute__ ((__packed__)); > : char pack_type __attribute__ ((__packed__)); > : short nr_rows __attribute__ ((__packed__)); > : short pattern_data_size __attribute__ ((__packed__)); > : }; > > You can just put the attribute at the end of the structure too: > > struct SXM_Pat_header { > > } __attribute__((packed)); > > This saves a lot of typing! But note that this doesn't work in C++, only in C. In C++ you need to put the attribute after each struct member. (FAQ section 22.10.) > BTW I don't think you need the double > underscores on the packed part - it works for me without. Is it supposed > to have double underscores? GCC accepts both, but -ansi complains if you don't use the underscores. It is always safer to have the underscores when you use non-standard extensions (like __inline__ etc.), they run a lesser risk of clashing with some global symbol defined by some third-party software.