delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/08/15:37:29

Sender: nate AT cartsys DOT com
Message-ID: <35F58092.D51AE72E@cartsys.com>
Date: Tue, 08 Sep 1998 12:08:02 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
MIME-Version: 1.0
To: yonghlee <yonghlee AT keysoft DOT lgec DOT co DOT kr>
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>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019