catch_config_uncaught_exceptions.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright Catch2 Authors
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // https://www.boost.org/LICENSE_1_0.txt)
  5. // SPDX-License-Identifier: BSL-1.0
  6. /** \file
  7. * Wrapper for UNCAUGHT_EXCEPTIONS configuration option
  8. *
  9. * For some functionality, Catch2 requires to know whether there is
  10. * an active exception. Because `std::uncaught_exception` is deprecated
  11. * in C++17, we want to use `std::uncaught_exceptions` if possible.
  12. */
  13. #ifndef CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP
  14. #define CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP
  15. #if defined(_MSC_VER)
  16. # if _MSC_VER >= 1900 // Visual Studio 2015 or newer
  17. # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
  18. # endif
  19. #endif
  20. #include <exception>
  21. #if defined(__cpp_lib_uncaught_exceptions) \
  22. && !defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
  23. # define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
  24. #endif // __cpp_lib_uncaught_exceptions
  25. #if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) \
  26. && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) \
  27. && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
  28. # define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
  29. #endif
  30. #endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP