From: lium@i-net.com.cn
To: gcc-help@gcc.gnu.org <gcc-help@gcc.gnu.org>,
gcc-help-help@gcc.gnu.org <gcc-help-help@gcc.gnu.org>
Subject: help: sizeof(struct)
Date: Mon, 15 Jul 2002 19:49:00 -0000 [thread overview]
Message-ID: <GZBMHQ00.EL5@mail.i-net.com.cn> (raw)
[-- Attachment #1: Type: text/plain, Size: 1499 bytes --]
Hi,
there is a struct like following:
struct test {
unsigned char a;
unsigned int b;
unsigned char c;
}
my target machine is ARM7TDMI, my gcc version is: "gcc version 3.0". when i use sizeof(struct test), it return 0xc. if i add 'packed' attribute, sizeof return 6. but i need the sizeof macro return 9.
the follow is memory layout:
Normal: +---+---+---+---+ Packed: +---+---+---+---+
|///|///|///|///| |///|///|///|///|
+---+---+---+---+ +---+---+---+---+
| a | | | | | a | b | b | b |
+---+---+---+---+ +---+---+---+---+
| b | b | b | b | | b | c |///|///|
+---+---+---+---+ +---+---+---+---+
| c | | | | |///|///|///|///|
+---+---+---+---+ +---+---+---+---+
Wanted: +---+---+---+---+
|///|///|///|///|
+---+---+---+---+
| a | | | |
+---+---+---+---+
| b | b | b | b |
+---+---+---+---+
| c |///|///|///|
+---+---+---+---+
would you please tell me which compiling option can do so.
[-- Attachment #2: Rabbit.GIF --]
[-- Type: image/gif, Size: 1488 bytes --]
next reply other threads:[~2002-07-16 2:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-15 19:49 lium [this message]
2002-07-16 2:19 ` Claudio Bley
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=GZBMHQ00.EL5@mail.i-net.com.cn \
--to=lium@i-net.com.cn \
--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).