Boost logo

Boost :

Subject: Re: [boost] [Boost.Config] Stlport patch for Sun compilers on Linux
From: Noel Belcourt (kbelco_at_[hidden])
Date: 2008-10-19 16:39:07


Peter Dimov <pdimov <at> pdimov.com> writes:

> K. Noel Belcourt:
> >
> > I'm not well versed with the subtleties of Stlport (there may be
> > better ways to code this). The patch merely avoids defining macro
> > BOOST_NO_EXCEPTION_STD_NAMESPACE as the Stlport bundled with the Sun
> > compilers on Linux seems to correctly put all type_info into the std
> > namespace. The Sun compilers on Solaris still require this macro
> > definition.
>
> There is something wrong with these macros and their use.
> BOOST_NO_EXCEPTION_STD_NAMESPACE should ostensibly be defined when there is
> no std::exception. But there are places in Boost, throw_exception.hpp and
> detail/bad_weak_ptr.hpp for example, that use std::exception, without
> checking the macro. Many libraries include, directly or indirectly, one of
> these two headers. If the macro is correctly set for Sun CC on Solaris, they
> should fail to compile. But the absence of bug reports implies that they
> don't.

Okay, I've removed this macro definition from boost/config/stdlib/stlport.hpp
as it's apparently no longer needed for stlport builds.

Index: boost/config/stdlib/stlport.hpp
===============================================
--- boost/config/stdlib/stlport.hpp (revision 49393)
+++ boost/config/stdlib/stlport.hpp (working copy)
@@ -127,7 +127,6 @@
          || defined(_STLP_USE_OWN_NAMESPACE)) \
       && (defined(__STL_VENDOR_GLOBAL_CSTD) \
      || defined (_STLP_VENDOR_GLOBAL_CSTD))
 # define BOOST_NO_STDC_NAMESPACE
-# define BOOST_NO_EXCEPTION_STD_NAMESPACE
 # endif
 #elif defined(__BORLANDC__) && __BORLANDC__ < 0x560
 // STLport doesn't import std::abs correctly:

Per Peter's suggestion, I've modified throw_exception.hpp and
detail/bad_weak_ptr.hpp to condition the use of std::exception on
BOOST_NO_EXCEPTION_STD_NAMESPACE.

Index: boost/detail/bad_weak_ptr.hpp
===============================================
--- boost/detail/bad_weak_ptr.hpp (revision 49393)
+++ boost/detail/bad_weak_ptr.hpp (working copy)
@@ -23,6 +23,12 @@
 # pragma warn -8026 // Functions with excep. spec. are not expanded inline
 #endif
 
+#if defined(BOOST_NO_EXCEPTION_STD_NAMESPACE)
+# define BOOST_STD_EXCEPTION ::exception
+#else
+# define BOOST_STD_EXCEPTION std::exception
+#endif
+
 namespace boost
 {
 
@@ -36,7 +42,7 @@
 # pragma option push -pc
 #endif
 
-class bad_weak_ptr: public std::exception
+class bad_weak_ptr: public BOOST_STD_EXCEPTION
 {
 public:
 

Index: boost/throw_exception.hpp
================================================
--- boost/throw_exception.hpp (revision 49393)
+++ boost/throw_exception.hpp (working copy)
@@ -43,16 +43,22 @@
 # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
 #endif
 
+#if defined( BOOST_NO_EXCEPTION_STD_NAMESPACE )
+# define BOOST_STD_EXCEPTION ::exception
+#else
+# define BOOST_STD_EXCEPTION std::exception
+#endif
+
 namespace boost
 {
 
 #ifdef BOOST_NO_EXCEPTIONS
 
-void throw_exception( std::exception const & e ); // user defined
+void throw_exception( BOOST_STD_EXCEPTION const & e ); // user defined
 
 #else
 
-inline void throw_exception_assert_compatibility( std::exception const & ) { }
+void throw_exception_assert_compatibility( BOOST_STD_EXCEPTION const & ) { }
 
 template<class E> inline void throw_exception( E const & e )
 {

> The only compiler I know of that doesn't have type_info in std is Embedded
> VC++ 4.2; it is what prompted me to ask for the addition of
> BOOST_NO_STD_TYPEINFO to make shared_ptr compile. Even eVC++ 4.2 is able to
> eat std::exception though (if I recall).

I've patched function_base.hpp to use the typeinfo,
rather than the exception, macro.

Index: boost/function/function_base.hpp
================================================
--- boost/function/function_base.hpp (revision 49393)
+++ boost/function/function_base.hpp (working copy)
@@ -42,7 +42,7 @@
 #endif
 
 // Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
-#ifdef BOOST_NO_EXCEPTION_STD_NAMESPACE
+#ifdef BOOST_NO_STD_TYPEINFO
 // Embedded VC++ does not have type_info in namespace std
 # define BOOST_FUNCTION_STD_NS
 #else

Any objection if I commit these to trunk?

-- Noel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk