Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error making less C for C++20. #574

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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