@@ -31,15 +31,15 @@ namespace detail {
31
31
// Lightweight std::source_location.
32
32
struct source_location {
33
33
const char * const file;
34
- // const char* const function; // disabled for now due to static constexpr restrictions
35
34
const int line;
36
35
constexpr source_location (
37
- // const char* _function /*= __builtin_FUNCTION()*/,
38
- const char * _file = __builtin_FILE(),
39
- int _line = __builtin_LINE()
40
- ) : file(_file), /* function(_function),*/ line(_line) {}
36
+ const char * _file,
37
+ int _line
38
+ ) : file(_file), line(_line) {}
41
39
};
42
40
41
+ #define CPPTRACE_CURRENT_LOCATION ::cpptrace::detail::source_location (__FILE__, __LINE__)
42
+
43
43
enum class assert_type {
44
44
assert ,
45
45
verify,
@@ -117,7 +117,7 @@ namespace detail {
117
117
}
118
118
119
119
// Check condition in both debug and release. std::runtime_error on failure.
120
- #define PANIC (...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, {} , ::cpptrace::detail::as_string(__VA_ARGS__)))
120
+ #define PANIC (...) ((::cpptrace::detail::panic)(CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION , ::cpptrace::detail::as_string(__VA_ARGS__)))
121
121
122
122
template <typename T>
123
123
void assert_impl (
@@ -153,13 +153,13 @@ namespace detail {
153
153
154
154
// Check condition in both debug and release. std::runtime_error on failure.
155
155
#define VERIFY (...) ( \
156
- assert_impl (__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, {} ) \
156
+ assert_impl (__VA_ARGS__, ::cpptrace::detail::assert_type::verify, #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION ) \
157
157
)
158
158
159
159
#ifndef NDEBUG
160
160
// Check condition in both debug. std::runtime_error on failure.
161
161
#define ASSERT (...) ( \
162
- assert_impl (__VA_ARGS__, ::cpptrace::detail::assert_type::assert , #__VA_ARGS__, CPPTRACE_PFUNC, {} ) \
162
+ assert_impl (__VA_ARGS__, ::cpptrace::detail::assert_type::assert , #__VA_ARGS__, CPPTRACE_PFUNC, CPPTRACE_CURRENT_LOCATION ) \
163
163
)
164
164
#else
165
165
// Check condition in both debug. std::runtime_error on failure.
0 commit comments