From: Erik Mouw <erik@harddisk-recovery.com>
To: Ren? Scharfe <rene.scharfe@lsrfire.ath.cx>
Cc: Andy Whitcroft <apw@shadowen.org>, Gerrit Pape <pape@smarden.org>,
git@vger.kernel.org
Subject: Re: sizeof(struct ...)
Date: Thu, 23 Nov 2006 16:54:31 +0100 [thread overview]
Message-ID: <20061123155431.GD6581@harddisk-recovery.com> (raw)
In-Reply-To: <4565C205.8050300@lsrfire.ath.cx>
On Thu, Nov 23, 2006 at 04:45:09PM +0100, Ren? Scharfe wrote:
> Andy Whitcroft schrieb:
> > You see packing attributes applied to similar things in the kernel.
> > Perhaps they are relevant here?
> > Is there not some kind of attribute thing we can apply to this structure
> > to prevent the padding? You see that in the kernel from time to time.
> >
> > struct foo {
> > } __attribute__((packed));
>
> Yes, that would be nice, but unfortunately __attribute__ is no standard
> C.
There is no standard C way to pack structures. Some compilers use
#pragma's, gcc uses __attribute__((packed)).
> Is there really a compiler that inserts padding between arrays of
> unsigned chars?
Yes, that compiler is called "gcc".
#include <stdio.h>
struct foo {
unsigned char a[3];
unsigned char b[3];
};
int main(void)
{
printf("%d\n", sizeof(struct foo));
return 0;
}
On i386 that prints 6, on ARM it prints 8.
Erik
--
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
next prev parent reply other threads:[~2006-11-23 15:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-23 10:16 sizeof(struct ...) Gerrit Pape
2006-11-23 12:43 ` René Scharfe
2006-11-23 13:38 ` René Scharfe
2006-11-23 13:55 ` Andy Whitcroft
2006-11-23 15:45 ` René Scharfe
2006-11-23 15:54 ` Erik Mouw [this message]
2006-11-23 16:14 ` René Scharfe
2006-11-23 16:19 ` Andy Whitcroft
2006-11-23 17:57 ` René Scharfe
2006-11-23 16:42 ` Erik Mouw
2006-11-23 20:47 ` Junio C Hamano
2006-11-23 22:02 ` [PATCH] archive-zip: don't use " René Scharfe
2006-11-24 8:53 ` Gerrit Pape
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=20061123155431.GD6581@harddisk-recovery.com \
--to=erik@harddisk-recovery.com \
--cc=apw@shadowen.org \
--cc=git@vger.kernel.org \
--cc=pape@smarden.org \
--cc=rene.scharfe@lsrfire.ath.cx \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.