diff --git a/src/utils/error.hpp b/src/utils/error.hpp index 19f017f..f1ced12 100644 --- a/src/utils/error.hpp +++ b/src/utils/error.hpp @@ -31,15 +31,17 @@ namespace detail { // Lightweight std::source_location. struct source_location { const char* const file; - //const char* const function; // disabled for now due to static constexpr restrictions + // const char* const function; // disabled, because there are many different compiler definitions for it (see for example BOOST_CURRENT_FUNCTION) const int line; constexpr source_location( - //const char* _function /*= __builtin_FUNCTION()*/, - const char* _file = __builtin_FILE(), - int _line = __builtin_LINE() - ) : file(_file), /*function(_function),*/ line(_line) {} + const char* _file, + //const char* _function, + int _line + ) : file(_file)/*, function(_function)*/, line(_line) {} }; + #define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location(__FILE__, __LINE__) + enum class assert_type { assert, verify, @@ -117,7 +119,7 @@ namespace detail { } // Check condition in both debug and release. std::runtime_error on failure. - #define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, {}, ::cpptrace::detail::as_string(__VA_ARGS__))) + #define PANIC(...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION, ::cpptrace::detail::as_string(__VA_ARGS__))) template void assert_impl( @@ -153,13 +155,13 @@ namespace detail { // Check condition in both debug and release. std::runtime_error on failure. #define VERIFY(...) ( \ - assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ + assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \ ) #ifndef NDEBUG // Check condition in both debug. std::runtime_error on failure. #define ASSERT(...) ( \ - assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, {}) \ + assert_impl(__VA_ARGS__, ::cpptrace::detail::assert_type::assert, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION) \ ) #else // Check condition in both debug. std::runtime_error on failure.