mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
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:
@ -15,12 +15,8 @@ project
|
|||||||
<library>/boost/system//boost_system
|
<library>/boost/system//boost_system
|
||||||
<toolset>msvc:<asynch-exceptions>on
|
<toolset>msvc:<asynch-exceptions>on
|
||||||
;
|
;
|
||||||
|
|
||||||
lib throw_test
|
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
|
||||||
: throw_test.cpp
|
|
||||||
: <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
|
|
||||||
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
|
|
||||||
;
|
|
||||||
|
|
||||||
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
|
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 ;
|
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
|
||||||
|
@ -21,19 +21,13 @@
|
|||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace boost
|
void throw_test();
|
||||||
{
|
|
||||||
namespace system
|
|
||||||
{
|
|
||||||
BOOST_SYSTEM_DECL void throw_test();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::system::throw_test();
|
throw_test();
|
||||||
}
|
}
|
||||||
catch (const boost::system::system_error& ex)
|
catch (const boost::system::system_error& ex)
|
||||||
{
|
{
|
||||||
@ -41,7 +35,6 @@ int main()
|
|||||||
std::cout << " what() reports " << ex.what() << '\n';
|
std::cout << " what() reports " << ex.what() << '\n';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (const std::runtime_error& ex)
|
catch (const std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";
|
std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";
|
||||||
|
@ -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/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
|
throw boost::system::system_error( 9999, boost::system::system_category(), "boo boo" );
|
||||||
{
|
|
||||||
BOOST_SYSTEM_DECL void throw_test()
|
|
||||||
{
|
|
||||||
throw system_error(9999, system_category(), "boo boo");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user