From d28c6ff1287d21b1541ce62cde0f183307b3237c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 14 Jan 2018 05:56:15 +0200 Subject: [PATCH] Do not put categories in an unnamed namespace, as this is an ODR violation in header-only mode --- include/boost/system/detail/error_code.ipp | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index b712de7..f3d67b9 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -38,7 +38,7 @@ namespace boost namespace system { -namespace +namespace detail { // standard error categories -------------------------------------------------------// @@ -60,14 +60,20 @@ namespace error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; }; +#ifdef BOOST_ERROR_CODE_HEADER_ONLY +# define BOOST_SYSTEM_INLINE inline +#else +# define BOOST_SYSTEM_INLINE +#endif + // generic_error_category implementation ---------------------------------// - const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT + BOOST_SYSTEM_INLINE const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "generic"; } - std::string generic_error_category::message( int ev ) const + BOOST_SYSTEM_INLINE std::string generic_error_category::message( int ev ) const { using namespace boost::system::errc; #if defined(__PGI) @@ -160,12 +166,12 @@ namespace } // system_error_category implementation --------------------------------------------// - const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT + BOOST_SYSTEM_INLINE const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const + BOOST_SYSTEM_INLINE error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { using namespace boost::system::errc; @@ -370,13 +376,13 @@ namespace # if !defined( BOOST_WINDOWS_API ) - std::string system_error_category::message( int ev ) const + BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const { return generic_category().message( ev ); } # else - std::string system_error_category::message( int ev ) const + BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const { #if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS) std::wstring buf(128, wchar_t()); @@ -455,7 +461,9 @@ namespace } # endif -} // unnamed namespace +#undef BOOST_SYSTEM_INLINE + +} // namespace detail # ifdef BOOST_SYSTEM_ENABLE_DEPRECATED @@ -474,13 +482,13 @@ namespace BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT { - static const system_error_category system_category_const; + static const detail::system_error_category system_category_const; return system_category_const; } BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT { - static const generic_error_category generic_category_const; + static const detail::generic_error_category generic_category_const; return generic_category_const; }