Fix throw_test.cpp to not meddle with BOOST_SYSTEM_SOURCE as it needs to import from Boost.System while exporting throw_test()

This commit is contained in:
Peter Dimov
2018-09-16 04:32:33 +03:00
parent 7a06df877d
commit 41de9d916a
3 changed files with 13 additions and 27 deletions

View File

@ -15,12 +15,8 @@ project
<library>/boost/system//boost_system
<toolset>msvc:<asynch-exceptions>on
;
lib throw_test
: throw_test.cpp
: <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
;
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;

View File

@ -21,19 +21,13 @@
#include <boost/system/system_error.hpp>
#include <iostream>
namespace boost
{
namespace system
{
BOOST_SYSTEM_DECL void throw_test();
}
}
void throw_test();
int main()
{
try
{
boost::system::throw_test();
throw_test();
}
catch (const boost::system::system_error& ex)
{
@ -41,7 +35,6 @@ int main()
std::cout << " what() reports " << ex.what() << '\n';
return 0;
}
catch (const std::runtime_error& ex)
{
std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";

View File

@ -13,19 +13,16 @@
//--------------------------------------------------------------------------------------//
// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_SYSTEM_SOURCE
#include <boost/system/system_error.hpp>
#include <boost/config.hpp>
namespace boost
#if defined(THROW_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
EXPORT void throw_test()
{
namespace system
{
BOOST_SYSTEM_DECL void throw_test()
{
throw system_error(9999, system_category(), "boo boo");
}
}
throw boost::system::system_error( 9999, boost::system::system_category(), "boo boo" );
}