Date: Thu, 13 Nov 1997 22:38:30 -0800 (PST) Message-Id: <199711140638.WAA20781@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: johan AT technologist DOT com (Johan Levin), djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Struct field aligning Precedence: bulk At 06:40 11/13/1997 GMT, Johan Levin wrote: >struct test_struct { > int p1; > char ch; > int p2; >}; >[snipped] >In this case all elements of the structure becomes >dword-aligned. That might be good for speed, but >I'm trying to read the header of a file that doesn't >align it's fields like this. Is it possible to disable >this aligning for a structure? Yes. GCC has a field attribute called `packed'. It's in the Info docs; try: info "gcc" "c extensions" "variable attributes" Basically, what you want will look something like this: struct test_struct { int p1 __attribute__((packed)); char ch __attribute__((packed)); int p2 __attribute__((packed)); }; HTH Nate Eldredge eldredge AT ap DOT net