Fix MinGW link errors by properly exporting symbols

This commit is contained in:
Peter Dimov
2018-01-22 02:20:01 +02:00
parent fe28fa163c
commit 77817d8847
3 changed files with 53 additions and 49 deletions

View File

@ -43,19 +43,14 @@ namespace detail
{
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_INLINE inline
# define BOOST_SYSTEM_DECL_ inline
#else
# define BOOST_SYSTEM_INLINE
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
// generic_error_category implementation ---------------------------------//
BOOST_SYSTEM_INLINE const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
BOOST_SYSTEM_INLINE std::string generic_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string generic_error_category::message( int ev ) const
{
using namespace boost::system::errc;
#if defined(__PGI)
@ -148,12 +143,7 @@ namespace detail
}
// system_error_category implementation --------------------------------------------//
BOOST_SYSTEM_INLINE const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
BOOST_SYSTEM_INLINE error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_DECL_ error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_NOEXCEPT
{
using namespace boost::system::errc;
@ -358,13 +348,13 @@ namespace detail
# if !defined( BOOST_WINDOWS_API )
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ std::string system_error_category::message( int ev ) const
{
return generic_category().message( ev );
}
# else
BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
BOOST_SYSTEM_DECL_ 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());
@ -443,7 +433,7 @@ namespace detail
}
# endif
#undef BOOST_SYSTEM_INLINE
#undef BOOST_SYSTEM_DECL_
} // namespace detail
@ -474,17 +464,17 @@ namespace detail
namespace detail
{
BOOST_SYSTEM_CONST_INIT const system_error_category system_category_const;
BOOST_SYSTEM_CONST_INIT const generic_error_category generic_category_const;
BOOST_SYSTEM_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
BOOST_SYSTEM_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return system_category_const;
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
return generic_category_const;
return generic_category_instance;
}
} // namespace detail
@ -498,14 +488,14 @@ namespace detail
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_const;
return system_category_const;
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_const;
return generic_category_const;
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
} // namespace detail

View File

@ -338,37 +338,53 @@ namespace boost
namespace detail
{
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_DECL_
#else
# define BOOST_SYSTEM_DECL_ BOOST_SYSTEM_DECL
#endif
class generic_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR generic_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "generic";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
};
class system_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR system_error_category(){}
const char * name() const BOOST_SYSTEM_NOEXCEPT;
std::string message( int ev ) const;
error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
const char * name() const BOOST_SYSTEM_NOEXCEPT
{
return "system";
}
BOOST_SYSTEM_DECL_ std::string message( int ev ) const;
BOOST_SYSTEM_DECL_ error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
};
#undef BOOST_SYSTEM_DECL_
} // namespace detail
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
BOOST_SYSTEM_CONSTEXPR inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::system_error_category system_category_const;
return system_category_const;
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
BOOST_SYSTEM_CONSTEXPR inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
static const detail::generic_error_category generic_category_const;
return generic_category_const;
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
@ -376,19 +392,19 @@ BOOST_SYSTEM_CONSTEXPR inline const error_category & generic_category() BOOST_SY
namespace detail
{
extern const system_error_category system_category_const;
extern const generic_error_category generic_category_const;
extern system_error_category system_category_instance;
extern generic_error_category generic_category_instance;
} // namespace detail
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::system_category_const;
return detail::system_category_instance;
}
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{
return detail::generic_category_const;
return detail::generic_category_instance;
}
#else

View File

@ -38,7 +38,6 @@ static void test_generic_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
static void test_system_category()
@ -47,7 +46,6 @@ static void test_system_category()
std::error_category const & st = bt;
BOOST_TEST_CSTR_EQ( bt.name(), st.name() );
BOOST_TEST_EQ( bt.name(), st.name() );
}
int main()