This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C ABI: struct/union inconsistency


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]