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


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

Re: __cplusplus revisited (on Solaris 8)


On Tue, 20 Feb 2001, Benjamin Kosnik wrote:
> 
> You need to use the include/c headers, not include/c_std. Did you do that 
> part? (Note this can be switched with a config option, see the web config 
> page)
> 
> since the solaris headers are so-called "std-namespace-ready" we don't 
> need to fool around with them, and can just pass through directly to them.

I just haven't been able to get things to work on Solaris 8 when __cplusplus is set to 199711L for compliance with
the C++ standard, and here's why.

The system headers that come with out-of-the-box Solaris 8 are fully compliant with section D.1.5.2 of the C++
standard, that is they provide the required names in both global and std namespaces.  They do this by declaring the
names in the std namespace in a set of header files (in /usr/include/iso), and then injecting them into the global
namespace via using declarations in the system headers.

The Sun WS6 compiler supplies its own standard C++ header files which do nothing but include the /usr/include/iso
header files directly.

None of this is a problem for the WS6 compiler or for GCC 2.95.2 because neither compiler respects clause 7.3.3.1 of
the C++ standard regarding the uniqueness of names in using declarations.  GCC 3.x complies with this clause, causing
all sorts of name clashes between various headers.

By patching a couple of system headers I can manage to get a bootstrap of the 3.x complier (with the c_std headers),
but simple test programs will not compile due to name clashes.  Any attempt to use the "c" or "c_shadow" C++ headers
instead of the "c_std" headers will not event bootstrap due to massive name clashes throughout the headers.  The "c"
headers won't work because they leave everything in std in the global namespace as well, so you can't include, say,
<unistd.h> and <cstdio> in the same program.  The "c_shadow" headers have other, more bizarre problems the cause of
which I'm still trying to track, but I don't think they really do what we want (although they should, in theory, do
what we need in a very roundabout way).

I think what we need in the case of Soalris 8 is a fourth set of C++ headers that are designed to wrap the
D.1.5.2-compliant  headers and just let the std names show through.  They would just do something like

// for <cstring>

namespace _system_header_
{
# include <string.h>
}

namespace std
{
  using namespace _system_header_::std;
}

// end of <cstring>


Is this a good idea or should I continue to hack away at perhaps getting c_shadow headers to work?


Stephen m. Webb


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