This is the mail archive of the
mailing list for the GCC project.
Re: RFC: attribute "unpadded"
On 26-Aug-2002, Mark Mitchell <email@example.com> wrote:
> There's no point arguing about the specific extension. It is what it
> is, warts and all. I will not argue it is pretty.
> However, it is the one extension that will naturally express the thing
> that the C++ ABI does; that ABI creates types whose sizes are not multiples
> of their alignments by ignoring tail padding. If you were to create a
> type-theoretic calculus for the ABI, you would need these types.
> So, the debate we should be having is one about the user-level feature
> of being able to emulate the C++ ABI in other languages. If we want
> to be able to do this, we need this extension. If we don't think that's
> important, then I'll withdraw the proposal.
What's the advantage *for users* in being able to emulate the C++ ABI in C?
I can see why this would be useful for the GCC implementors, to implement
GCC's own internal test suite. But for users of GCC who need to
define or use structures that are layout-compatible with particular
C++ structures, I think it would make more sense to just write C++ code
that uses the original C++ definitions of these structures.
If these structures need to be accessed from C, it's always possible to
write access routines (get_field_1, set_field_1, etc.) in C++, and
export them to C using `extern "C"'. This approach has the advantage
that it is more portable: it doesn't matter which C++ ABI the compiler
uses, and it doesn't require the C compiler to support this attribute
> Here is what I am going to do at this point: implement the extension,
> and use it for myself. I will check it in after GCC 3.3 branches --
> unless a maintainer asks me not to do so.
Implementing it as an extension might (currently) be the easiest way
to implement a good test suite for the C++ ABI. So I would not object
to it being added for that purpose. However, if there is no pressing
*user* need for it, then I think it might be a mistake to document it
as an offically supported extension at this point.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.