Skip to content

Commit

Permalink
fatal error making less C for C++20. (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored Dec 9, 2022
1 parent 0a5eb40 commit dd3f4a9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/snmalloc/ds_core/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ namespace snmalloc
#define TOSTRING(expr) TOSTRING2(expr)
#define TOSTRING2(expr) #expr

#if (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 11) || \
(defined(__clang__) && __clang_major__ >= 15)
# include <source_location>
# define SNMALLOC_CURRENT_LINE std::source_location::current().line()
# define SNMALLOC_CURRENT_FILE std::source_location::current().file_name()
#else
# define SNMALLOC_CURRENT_LINE TOSTRING(__LINE__)
# define SNMALLOC_CURRENT_FILE __FILE__
#endif

#ifdef NDEBUG
# define SNMALLOC_ASSERT_MSG(...) \
{}
Expand All @@ -121,8 +131,8 @@ namespace snmalloc
snmalloc::report_fatal_error( \
"assert fail: {} in {} on {} " fmt "\n", \
#expr, \
__FILE__, \
TOSTRING(__LINE__), \
SNMALLOC_CURRENT_FILE, \
SNMALLOC_CURRENT_LINE, \
##__VA_ARGS__); \
} \
} while (0)
Expand All @@ -137,8 +147,8 @@ namespace snmalloc
snmalloc::report_fatal_error( \
"Check fail: {} in {} on {} " fmt "\n", \
#expr, \
__FILE__, \
TOSTRING(__LINE__), \
SNMALLOC_CURRENT_FILE, \
SNMALLOC_CURRENT_LINE, \
##__VA_ARGS__); \
} \
} while (0)
Expand Down

0 comments on commit dd3f4a9

Please sign in to comment.