cpplib: Fix __cplusplus definition

Phil Edwards pedwards@disaster.jaj.com
Fri Jan 26 12:13:00 GMT 2001

On Fri, Jan 26, 2001 at 10:41:10AM -0500, Phil Edwards wrote:
> > Neil Booth <neil@daikokuya.demon.co.uk> writes:
> > 
> > | Phil / Gabriel,
> > | 
> > | I found a libstdc++ thread on Google with you two discussing the
> > | problems found when we define __cplusplus correctly.
> > | 
> > | Is this patch OK to commit?
> This afternoon I will try your patch and provide a better description of
> the breakage.  Maybe there's a not-too-painful workaround.

Well, let me write this up while the build is proceeding.  I don't have
anything older than Solaris 8 to test this on, so I suspect we're okay on
previous OS versions.

I have to give credit to Sun; the headers under Solaris 8 are actually
fairly well-designed towards standards compliance... at least for their
own compiler; they're not expecting someone to come along and do all the
work over again, like we are.  :-)  Header /usr/include/foo.h usually
starts off by including <iso/foo_iso.h>, which does all the declarations,
possibly wrapped in namespace std.  Then foo.h tests __cplusplus not for
simple existence, but against the value it's supposed to have, and if it
passes then some using directives take place to expose the names.

So, stdio.h looks like

    #include <iso/stdio_iso.h>

    #if __cplusplus >= 199711L
    using std::FILE;
    using std::size_t;
    using std::fpos_t;
    using std::remove;
    using std::rename;

And then we start getting naming collisions in the standard library.
For starters, we can't even finish configuring:

running mknumeric_limits
/builddir/gcc/g++ -B/builddir/gcc/ -nostdinc++  -L/builddir/sparc-sun-solaris2.8/libstdc++-v3/src -L/builddir/sparc-sun-solaris2.8/libstdc++-v3/src/.libs -B/installdir/sparc-sun-solaris2.8/bin/ -B/installdir/sparc-sun-solaris2.8/lib/ -isystem /installdir/sparc-sun-solaris2.8/include -L/builddir/ld  -I/builddir/sparc-sun-solaris2.8/libstdc++-v3/include     -o /builddir/sparc-sun-solaris2.8/libstdc++-v3/src/gen-num-limits ../../../unified/libstdc++-v3/src/gen-num-limits.cc      -nodefaultlibs -lgcc -lc
In file included from ../../../unified/libstdc++-v3/src/gen-num-limits.cc:52:
/builddir/gcc/include/stdio.h:52: using directive `size_t'
   introduced ambiguous type `size_t'
In file included from /usr/include/sys/time.h:406,
                 from /usr/include/sys/select.h:17,
                 from /builddir/gcc/include/sys/types.h:569,
                 from /usr/include/signal.h:23,
                 from ../../../unified/libstdc++-v3/src/gen-num-limits.cc:53:
/usr/include/time.h:28: using directive `clock_t' introduced ambiguous type
/usr/include/time.h:29: using directive `time_t' introduced ambiguous type
gen-num-limits failed to build, exiting.
mknumeric_limits failed to execute properly: exiting
gmake: *** [configure-target-libstdc++-v3] Error 1


pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.

More information about the Libstdc++ mailing list