Mail Archives: djgpp/1998/09/08/15:37:29
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
- Raw text -