1 //  dynamic_link_test.cpp  -------------------------------------------------------------//
2 
3 //  Copyright Beman Dawes 2010
4 
5 //  Distributed under the Boost Software License, Version 1.0.
6 //  See www.boost.org/LICENSE_1_0.txt
7 
8 //  Library home page is www.boost.org/libs/system
9 
10 //--------------------------------------------------------------------------------------//
11 
12 //  Dynamic link libraries (DLL's), also know as dynamic shared objects (DSO's),
13 //  can cause symbol visability problems unless carefully configured. One of the
14 //  manifestations, particularly with GCC, is that a system_error exception thrown from
15 //  a DLL or DSO is not caught.
16 //
17 //  The purpose of this program is to test for that error.
18 
19 //--------------------------------------------------------------------------------------//
20 
21 #include <boost/system/system_error.hpp>
22 #include <iostream>
23 
24 void throw_test();
25 
main()26 int main()
27 {
28   try
29   {
30     throw_test();
31   }
32   catch (const boost::system::system_error& ex)
33   {
34     std::cout << "  caught boost::system::system_error as expected\n";
35     std::cout << "  what() reports " << ex.what() << '\n';
36     return 0;
37   }
38   catch (const std::runtime_error& ex)
39   {
40     std::cout << "  error: caught std::runtime_error instead of boost::system::system_error\n";
41     std::cout << "  what() reports " << ex.what() << '\n';
42     return 1;
43   }
44 
45   std::cout << "  error: failed to catch boost::system::system_error\n";
46   return 1;
47 }
48