dynamic_link_test.cpp 1.4 KB

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