Implications of tighter integration of libg++

Joe Buck jbuck@synopsys.com
Mon Feb 9 21:34:00 GMT 1998


I wrote:
> > say "using namespace std;" as that imports all names.  Rather, just
> > things like
> > 
> > using std::istream;
> > using std::ostream;
> > using std::cin;
> > using std::cout;
> > using std::cerr;

Martin von Loewis writes:
> This does not solve the problem I'm talking about. With that scheme,
> and the implementation of namespace I have in mind, names would still
> come out as Q23std7istream, rather than 7istream as they do now. This
> is because the compiler would always resolve names to the place where
> they are actually introduced, regardless of any using and typedef
> magic applied.
> 
> So, even if old sources would still compile, old objects would not
> link anymore. This is especially bad in presence of shared libraries
> which have to accomodate both sets of header files.

If the only issue were that library functions and data definitions move
into std, we could solve it in the linker: GNU ld would get a list of
names to be remapped, and it would make old programs link by means of
name remapping for identifiers that would otherwise be undefined.

Unfortunately, iostreams needs to get a much bigger rewrite: not only
do istream and ostream move into std, but they are really
basic_istream<char> and basic_ostream<char>.  A number of access
functions change as well.

Even so, perhaps a backward compatibility layer could be written.  But it
might be easier just to ship two libstdc++ versions with different major
version numbers than to try to figure out how to make one library do.  The
whole reason for using the std namespace is so that users are freed up to
use the hundreds of names the standard library takes away.  Any scheme
that tries to preserve backward compatibility will also pollute the
namespace (preventing users from using certain identifier names), meaning
that we won't have a conforming compiler.

For that reason I think that the solution to binary compatibility is to
just bump the major version number on the shared library.  Users who must
run old binaries will need the old shared library, but the two versions
can co-exist on the same system.




More information about the Gcc mailing list