public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Shaun Jackman <sjackman@pathwayconnect.com>
To: gcc-help@gcc.gnu.org
Subject: Re: packed and aligned structures
Date: Wed, 12 Sep 2001 13:18:00 -0000	[thread overview]
Message-ID: <E15hGSt-0002Vq-00@dazed> (raw)

On the matter of exact structure size. I forget to mention I've already tried 
specifying -mstructure-size-boundary=8, which had the desired with 2.95.2. 
This doesn't seem to work with 3.0.1 though. Is it still a supported option? 

Thanks,
Shaun

On September 12, 2001 13:58, you wrote:
> I'm sure this is a common question, and I thought I had it solved in
> 2.95.2, but I've recent upgraded to 3.01 and the problem rears its ugly
> head again. Here's a basic rundown of what I'm looking for.
>
> All my protocol structures must be PACKED (no padding in the structure),
> EXACT SIZE (no padding at the end of the structure, if the structure is 13
> bytes long, sizeof( mystruct) should return 13, not 16), and ALIGNED to a 4
> byte boundary. What combination of attributes and command line switches can
> I use to accomplish this?
>
> --- ALIGNED ---
> In 2.95.2 all my structures always seemed to be on 4 byte
> boundaries regardless of content, however 3.01 put a structure of this form
> 	typedef struct {
> 		char pad[2];
> 		char data[ 1400];
> 	} mystruct;
> on a 2 byte boundary. Will
> 	} __attribute__((aligned(4))) mystruct;
> fix this? Is there a command line switch to force this for all structs?
>
> --- EXACT SIZE ---
> 	typedef struct {
> 		long src,
> 		long dst,
> 		char mbz,
> 		char prot,
> 		short len,
> 		short checksum
> 	} mystruct;
> sizeof( mystruct) returns 16, how do I make this return 14?
>
> --- PACKED ---
> 	typedef struct {
> 		...
> 	} __attribute__((packed)) mystruct;
> Will this force all the members of the structure to be packed (ie no
> padding in the structure)?
> 	typedef struct {
> 		...
> 	} __attribute__((packed, aligned(4))) mystruct;
> Does this construct make sense to force the structure to a 4 byte boundary,
> as well as packing the members?
>
> Many thanks,
> Please cc me as I'm not a member of the list,
> Shaun

             reply	other threads:[~2001-09-12 13:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-12 13:18 Shaun Jackman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-12 12:58 Shaun Jackman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E15hGSt-0002Vq-00@dazed \
    --to=sjackman@pathwayconnect.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).