From 4213fa8a986ccfdf03783638862a9aacf3ea8601 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 20 Oct 2022 23:25:32 +0200 Subject: rename macros --- compat/assert.hpp | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'compat') diff --git a/compat/assert.hpp b/compat/assert.hpp index 0d3efd09..44b401fa 100644 --- a/compat/assert.hpp +++ b/compat/assert.hpp @@ -9,23 +9,27 @@ # pragma GCC diagnostic ignored "-Wunused-macros" #endif -#define emit_debug(pfx, ...) \ - do { \ - if (!std::is_constant_evaluated()) { \ - if constexpr (sizeof(pfx) > 1) \ - std::fputs((pfx), stderr); \ - std::fprintf(stderr, __VA_ARGS__); \ - std::fputc('\n', stderr); \ - std::fflush(stderr); \ - } \ +#define fm_EMIT_DEBUG(pfx, ...) \ + do { \ + if (!std::is_constant_evaluated()) { \ + if constexpr (sizeof(pfx) > 1) \ + std::fputs((pfx), stderr); \ + std::fprintf(stderr, __VA_ARGS__); \ + std::fputc('\n', stderr); \ + std::fflush(stderr); \ + } \ } while (false) -#define ABORT(...) do { emit_debug("fatal: ", __VA_ARGS__); std::abort(); } while (false) +#define fm_abort(...) \ + do { \ + fm_EMIT_DEBUG("fatal: ", __VA_ARGS__); \ + std::abort(); \ + } while (false) -#define ASSERT(...) \ +#define fm_assert(...) \ do { \ if (!(__VA_ARGS__)) { \ - emit_debug("", "assertion failed: '%s' in %s:%d", \ + fm_EMIT_DEBUG("", "assertion failed: '%s' in %s:%d", \ #__VA_ARGS__, __FILE__, __LINE__); \ std::abort(); \ } \ @@ -34,20 +38,24 @@ #define ASSERT_EXPR(var, expr, cond) \ ([&] { \ decltype(auto) var = (expr); \ - ASSERT(cond); \ + fm_assert(cond); \ return (var); \ })() -#define WARN(...) emit_debug("warning: ", __VA_ARGS__) -#define ERR(...) emit_debug("error: ", __VA_ARGS__) -#define MESSAGE(...) emit_debug("", __VA_ARGS__) -#define DEBUG(...) emit_debug("", __VA_ARGS__) +#define fm_warn(...) fm_EMIT_DEBUG("warning: ", __VA_ARGS__) +#define fm_error(...) fm_EMIT_DEBUG("error: ", __VA_ARGS__) +#define fm_log(...) fm_EMIT_DEBUG("", __VA_ARGS__) +#define fm_debug(...) fm_EMIT_DEBUG("", __VA_ARGS__) + +#ifdef __GNUG__ +# pragma GCC diagnostic pop +#endif namespace floormat { template struct static_warning_ final { - [[deprecated]] constexpr static_warning_() = default; + [[deprecated("compile-time warning valuated to 'true'")]] constexpr static_warning_() = default; }; template<> @@ -59,6 +67,3 @@ struct static_warning_ final { } // namespace floormat -#ifdef __GNUG__ -# pragma GCC diagnostic pop -#endif -- cgit v1.2.3