summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-20 23:25:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-20 23:25:32 +0200
commit4213fa8a986ccfdf03783638862a9aacf3ea8601 (patch)
treee1d78e3dcc74ce6c2605ff31e035fb7e4ad36453 /compat
parentd22abc50862f7243228c93fd2fd3878b37821487 (diff)
rename macros
Diffstat (limited to 'compat')
-rw-r--r--compat/assert.hpp47
1 files changed, 26 insertions, 21 deletions
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<bool>
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_<true> final {
} // namespace floormat
-#ifdef __GNUG__
-# pragma GCC diagnostic pop
-#endif