This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Type name mangling
- To: egcs at cygnus dot com
- Subject: Re: Type name mangling
- From: Nathan Myers <ncm at best dot com>
- Date: Fri, 23 Oct 1998 05:38:18 -0700 (PDT)
Martin wrote:
> Nathan wrote:
> > The C library subset of the standard C++ library offers good
> > examples. It defines a type, "struct tm". C programmers are used
> > to forward-declaring struct tags to use in declaring functions --
> > as in
> >
> > struct tm;
> > void maraud(tm*);
>
> I'm not sure I see the problem. While this style might be a C
> tradition, C++ programmers have learned to provide #include statements
> to access structure definitions - at least since ostream is a typedef.
Yes, the problem isn't in C++ code, it's in C headers used by
C++ code. Suppose the above is in a C header. That tm is not
the same tm as std::tm; the compiler hasn't even seen std::tm,
but it will happily mangle ::tm into maraud's name.
However, if in a different compilation unit <time.h> happens to
have been included first, then there is a global alias for
std::tm, and then maraud will mangle differently.
Any actual tm objects are necessarily std::tm's, but pointers
passed to maraud might be either. The compiler will need to be
able to accommodate that.
C programmers are not going to give up their forward struct
declarations. (A lot of them still like implicit int.)
> So the problem really is with placing namespace std into <ctime>,
> right? This is but one of the transition problems related to namespace
> introduction, where the transition from <iostream.h> to <iostream> is
> much more serious.
Namespace std in <ctime> is an example of the problem, but
it's much more widespread.
> Users have come to accept that the ABI breaks between compiler
> versions. I doubt they would accept a language change as serious as
> the one you propose, if the current standard is not even completely
> implemented by most compilers.
Users will not continue accepting ABI breakage, and such breakage is
impeding acceptance of C++. Eventually we will have to settle
down and make some promises, but first we need something like
conformance.
Anyway, I'm not proposing a language change, only a compiler change,
to become part of -fnew-abi. A change like this appears necessary to
shoehorn the C headers into namespace std and still be able to
use C libraries. If users cannot link to C libraries without
-fno-honor-std, we will have failed.
Nathan Myers
ncm@cantrip.org