]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/system/test/dynamic_link_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / system / test / dynamic_link_test.cpp
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
23 #include <iostream>
24
25 namespace boost
26 {
27 namespace system
28 {
29 BOOST_SYSTEM_DECL void throw_test();
30 }
31 }
32
33 int main()
34 {
35 try
36 {
37 boost::system::throw_test();
38 }
39 catch (const boost::system::system_error& ex)
40 {
41 std::cout << " caught boost::system::system_error as expected\n";
42 std::cout << " what() reports " << ex.what() << '\n';
43 return 0;
44 }
45
46 catch (const std::runtime_error& ex)
47 {
48 std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";
49 std::cout << " what() reports " << ex.what() << '\n';
50 return 1;
51 }
52
53 std::cout << " error: failed to catch boost::system::system_error\n";
54 return 1;
55 }