diff --git a/include/fmt/format.h b/include/fmt/format.h index 207428d4..ecfc3c5f 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -80,39 +80,30 @@ FMT_BEGIN_NAMESPACE } FMT_END_NAMESPACE -#ifndef FMT_THROW -# if FMT_EXCEPTIONS -# if FMT_MSC_VER -//TODO: why is this only for MSVC builds? FMT_BEGIN_NAMESPACE -namespace internal { -#define FMT_FAST_FAIL 1 /*TODO: remove before relase, here for testing purposes */ -#if FMT_FAST_FAIL - template [[noreturn]] inline void do_throw(const Exception& x) { - terror(x.what()); - } -#else -template inline void do_throw(const Exception& x) { - // Silence unreachable code warnings in MSVC because these are nearly - // impossible to fix in a generic code. - volatile bool b = true; - if (b) throw x; +// terror == terminating error +[[noreturn]] inline void terror(const char msg_[BUFSIZ]) { + ::puts("\n\n\nFast exit on {fmt} error with message: "); + ::puts(msg_); + ::perror("\nPOSIX error message: "); + std::exit(EXIT_FAILURE); } +namespace internal { + template +#ifndef FMT_EXCEPTIONS + [[noreturn]] #endif + inline void do_throw(const Exception& x) { +#if FMT_EXCEPTIONS + throw x; +#else + terror(x.what()); +#endif + } } // namespace internal FMT_END_NAMESPACE -//TODO: why is do_throw() only for MSVC builds? -# define FMT_THROW(x) fmt :: internal::do_throw(x) -# else -# define FMT_THROW(x) throw x -# endif -# else -# define FMT_THROW(x) \ - do { \ - fmt :: terror(x.what()) \ - } while (false) -# endif -#endif + +#define FMT_THROW(x) fmt :: internal::do_throw(x) #ifndef FMT_USE_USER_DEFINED_LITERALS // For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs.