Sender: nate AT cartsys DOT com Message-ID: <35F58092.D51AE72E@cartsys.com> Date: Tue, 08 Sep 1998 12:08:02 -0700 From: Nate Eldredge MIME-Version: 1.0 To: yonghlee CC: djgpp AT delorie DOT com Subject: Re: "word aligned structure" compiling option References: <_ZJI1.392$XU4 DOT 1621018 AT news DOT bora DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk yonghlee wrote: > I want to know the gcc compiler option for word aligned structure > option > Here is my structure example; > > typedef struct my_APPstr { > UC A; > UC B[2]; > UC C[2]; > } Pmy_APPstr; > > I want the "sizeof(Pmy_APPstr)" as 6 . > When I used Borland C with "word align option", it returned with size "6" > And I don't want change my source code for target compatibility > as described in DJGPP FAQ list. Either: * Add `__attribute__((packed))' after the declaration, before the semicolon. (inside an #ifdef __GNUC__). See the GCC docs, node "C Extensions/Type Attributes" (I think). * Use the flag `-fpack-struct'. Note that this will render you unable to pass structs to and from the standard libraries, since they were not compiled with that option. It is also less efficient, since it packs even non-size critical structs. -- Nate Eldredge nate AT cartsys DOT com