From 27e7fd18f1c337c409f2a567697b27bcd0c09f8b Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Wed, 7 Jul 2021 17:12:12 -0400 Subject: Support manually disabling exceptions Rename EIGEN_EXCEPTIONS to EIGEN_USE_EXCEPTIONS, and allow disabling exceptions with -DEIGEN_USE_EXCEPTIONS=0. --- test/main.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'test/main.h') diff --git a/test/main.h b/test/main.h index 786673dea..77943040b 100644 --- a/test/main.h +++ b/test/main.h @@ -209,8 +209,12 @@ namespace Eigen #define EIGEN_DEFAULT_IO_FORMAT IOFormat(4, 0, " ", "\n", "", "", "", "") -#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__) && !defined(__SYCL_DEVICE_ONLY__) - #define EIGEN_EXCEPTIONS +#ifndef EIGEN_USE_EXCEPTIONS + #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(__CUDA_ARCH__) && !defined(__HIP_DEVICE_COMPILE__) && !defined(__SYCL_DEVICE_ONLY__) + #define EIGEN_USE_EXCEPTIONS 1 + #else + #define EIGEN_USE_EXCEPTIONS 0 + #endif #endif #ifndef EIGEN_NO_ASSERTION_CHECKING @@ -267,7 +271,7 @@ namespace Eigen eigen_assert_list.push_back(std::string(EIGEN_MAKESTRING(__FILE__) " (" EIGEN_MAKESTRING(__LINE__) ") : " #a) ); \ } - #ifdef EIGEN_EXCEPTIONS + #if EIGEN_USE_EXCEPTIONS #define VERIFY_RAISES_ASSERT(a) \ { \ Eigen::no_more_assert = false; \ @@ -286,7 +290,7 @@ namespace Eigen Eigen::report_on_cerr_on_assert_failure = true; \ Eigen::internal::push_assert = false; \ } - #endif //EIGEN_EXCEPTIONS + #endif //EIGEN_USE_EXCEPTIONS #elif !defined(__CUDACC__) && !defined(__HIPCC__) && !defined(SYCL_DEVICE_ONLY) // EIGEN_DEBUG_ASSERTS // see bug 89. The copy_bool here is working around a bug in gcc <= 4.3 @@ -300,7 +304,7 @@ namespace Eigen EIGEN_THROW_X(Eigen::eigen_assert_exception()); \ } - #ifdef EIGEN_EXCEPTIONS + #if EIGEN_USE_EXCEPTIONS #define VERIFY_RAISES_ASSERT(a) { \ Eigen::no_more_assert = false; \ Eigen::report_on_cerr_on_assert_failure = false; \ @@ -311,10 +315,10 @@ namespace Eigen catch (Eigen::eigen_assert_exception&) { VERIFY(true); } \ Eigen::report_on_cerr_on_assert_failure = true; \ } - #endif // EIGEN_EXCEPTIONS + #endif // EIGEN_USE_EXCEPTIONS #endif // EIGEN_DEBUG_ASSERTS - #if defined(TEST_CHECK_STATIC_ASSERTIONS) && defined(EIGEN_EXCEPTIONS) + #if defined(TEST_CHECK_STATIC_ASSERTIONS) && EIGEN_USE_EXCEPTIONS #define EIGEN_STATIC_ASSERT(a,MSG) \ if( (!Eigen::internal::copy_bool(a)) && (!no_more_assert) )\ { \ -- cgit v1.2.3