From 41de9d916a67fc3e9f4f78b3102ceb19adf0ffd0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 16 Sep 2018 04:32:33 +0300 Subject: [PATCH] Fix throw_test.cpp to not meddle with BOOST_SYSTEM_SOURCE as it needs to import from Boost.System while exporting throw_test() --- test/Jamfile.v2 | 8 ++------ test/dynamic_link_test.cpp | 11 ++--------- test/throw_test.cpp | 21 +++++++++------------ 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 784fd8e..037b004 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,12 +15,8 @@ project /boost/system//boost_system msvc:on ; - - lib throw_test - : throw_test.cpp - : shared:BOOST_SYSTEM_DYN_LINK=1 - static:BOOST_SYSTEM_STATIC_LINK=1 - ; + + lib throw_test : throw_test.cpp : shared:THROW_DYN_LINK=1 ; lib single_instance_lib1 : single_instance_1.cpp : shared:SINGLE_INSTANCE_DYN_LINK ; lib single_instance_lib2 : single_instance_2.cpp : shared:SINGLE_INSTANCE_DYN_LINK ; diff --git a/test/dynamic_link_test.cpp b/test/dynamic_link_test.cpp index b4c4615..8826f83 100644 --- a/test/dynamic_link_test.cpp +++ b/test/dynamic_link_test.cpp @@ -21,19 +21,13 @@ #include #include -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"; diff --git a/test/throw_test.cpp b/test/throw_test.cpp index c42f422..c7ae517 100644 --- a/test/throw_test.cpp +++ b/test/throw_test.cpp @@ -13,19 +13,16 @@ //--------------------------------------------------------------------------------------// -// define BOOST_SYSTEM_SOURCE so that knows -// the library is being built (possibly exporting rather than importing code) -#define BOOST_SYSTEM_SOURCE - #include +#include -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" ); }