/Src/Dependencies/Boost/libs/system/test/dynamic_link_test.cpp

http://hadesmem.googlecode.com/ · C++ · 55 lines · 30 code · 12 blank · 13 comment · 0 complexity · 025eb30c130a80ee8ca697603059f379 MD5 · raw file

  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. namespace boost
  17. {
  18. namespace system
  19. {
  20. BOOST_SYSTEM_DECL void throw_test();
  21. }
  22. }
  23. int main()
  24. {
  25. try
  26. {
  27. boost::system::throw_test();
  28. }
  29. catch (const boost::system::system_error& ex)
  30. {
  31. std::cout << " caught boost::system::system_error as expected\n";
  32. std::cout << " what() reports " << ex.what() << '\n';
  33. return 0;
  34. }
  35. catch (const std::runtime_error& ex)
  36. {
  37. std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n";
  38. std::cout << " what() reports " << ex.what() << '\n';
  39. return 1;
  40. }
  41. std::cout << " error: failed to catch boost::system::system_error\n";
  42. return 1;
  43. }