This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C ABI: struct/union inconsistency
- From: Gabriel Paubert <paubert at iram dot es>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: Richard Henderson <rth at redhat dot com>, "tim at hollebeek dot com"<tim at hollebeek dot com>, "David S. Miller" <davem at redhat dot com>, "gdr at integrable-solutions dot net"<gdr at integrable-solutions dot net>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 30 Sep 2002 18:13:30 +0200
- Subject: Re: C ABI: struct/union inconsistency
- References: <3760000.1033243470@warlock.codesourcery.com>
Mark Mitchell wrote:
struct foo {
#ifdef SMP
long long count;
long lock;
#endif
};
Here, attribute((nopadding)) would leave foo with size 12,
instead of the required size 16 when SMP is defined.
Ah, good point.
I hate it when I think I'm clever and then turn out not to be.
Hmm, what about attribute((collapse)), or collapse_empty_struct,
or something similar. I'm not a native english speaker, but I kind
of like the word "collapse" to describe this property. However I
may have been brainwashed by cosmologists in a previous life :-)
<devil>
Alternatively, it could be said that sizeof (struct S1 {}) is always
one, and we could invent a new syntax for zero sized structs
struct S2 {void};
whose size would _always_ be zero in C, C++, ObjC, ObjC++, C#...
Oh well, yet another devious GNU C-only syntax extension proposal.
Let me grab my asbestos suit before the flamefest starts.
</devil>
Regards,
Gabriel.