This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32016] sizeof(class) always a multiple of 4 on 32 bit machine
- From: "bliss1940-bbs at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 May 2007 00:16:24 -0000
- Subject: [Bug c++/32016] sizeof(class) always a multiple of 4 on 32 bit machine
- References: <bug-32016-9370@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from bliss1940-bbs at yahoo dot com 2007-05-22 01:16 -------
(In reply to comment #7)
> On arm-elf structures are padded/aligned to a 4-byte boundary. This is a
> "feature" of the ABI. The microsoft compiler obviously conforms to a different
> ABI, which is why you get different results. Both are "correct".
Thanks everyone for your time and trouble. I will go with the packed
attribute.
> Any code that relies on a particular structure layout or size is inherently
> unportable.
> EABI based targets (eg. arm-eabi) use a more conventional ABI.
Unfortunately so. I think that structures with only chars would be portable if
only compilers didn't pad the end of them. In fact my message classes are
portable between Microsoft on the PC and GNU on the ARM except for the sizeof()
thing.
Defining inter-computer messages as classes with functions to manipulate the
data inside is so very handy that I will continue to do it and will use the
__attribute__((packed)) whenever necessary.
Thanks again,
Steve
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32016