debug: defend against renaming of panic using macros

This commit is contained in:
Danny Robson 2018-08-24 17:31:34 +10:00
parent 676154d652
commit c5ed42ccbf
2 changed files with 19 additions and 1 deletions

View File

@ -32,6 +32,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
###############################################################################
add_library(cruft)
# Preemptively define an identity panic macro so that TCL doens't fuck us over
# by renaming a commonly used symbol.
target_compile_definitions(cruft PUBLIC "-Dpanic=panic")
###############################################################################
search_libs (BACKTRACE_LIB backtrace execinfo)

View File

@ -422,6 +422,19 @@ void breakpoint (void);
///////////////////////////////////////////////////////////////////////////////
// We define an identity macro for panic so that TCL and GCC don't decide to
// fuck us over by redefine the symbol.
//
// Apparently this can't be taken care of via a '-Dpanic=panic' argument,
// because it just ignores it for reasons I can't figure out.
#ifdef panic
#undef panic
#endif
#define panic panic
//-----------------------------------------------------------------------------
namespace cruft::debug::detail {
void
panic [[noreturn]] (const char *msg);
@ -434,7 +447,7 @@ namespace cruft::debug::detail {
}
//-----------------------------------------------------------------------------
constexpr void
panic [[noreturn]] (const char *msg)
{
@ -444,6 +457,7 @@ panic [[noreturn]] (const char *msg)
}
//-----------------------------------------------------------------------------
inline void
panic [[noreturn]] (const std::string &msg)
{