summaryrefslogtreecommitdiffhomepage
path: root/compat/assert.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-03 19:18:04 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-04 06:58:20 +0100
commit8f24fd992e39fdd91cad06c69d01e4561d8bf419 (patch)
treefef7cf234567b3a847c9043412bd12b0d22e8409 /compat/assert.hpp
parent0979263e1654259e6cac4be2e53ca022f7cbb6df (diff)
compat/assert: try harder to flush std{out,err}
Diffstat (limited to 'compat/assert.hpp')
-rw-r--r--compat/assert.hpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/compat/assert.hpp b/compat/assert.hpp
index abd834b9..363d418b 100644
--- a/compat/assert.hpp
+++ b/compat/assert.hpp
@@ -1,8 +1,15 @@
#pragma once
#include "defs.hpp"
-#include <cstdlib>
-#include <cstdio>
-#include <type_traits>
+#include <cstdlib> // todo speed up loading by moving printing into a .cpp file
+#include <cstdio> // idem.
+
+namespace floormat::assert_detail {
+
+
+#define fm_EMIT_ABORT() do { std::fflush(stdout); std::fflush(stderr); ::std::abort(); } while (false)
+
+} // namespace floormat::assert_detail
+
#ifdef __GNUG__
#pragma GCC diagnostic push
@@ -28,14 +35,13 @@
#define FM_KILL_PRINTF_WARN_2()
#endif
-#define fm_EMIT_ABORT() ::std::abort()
-
#define fm_EMIT_DEBUG2(pfx, ...) \
do { \
if (!std::is_constant_evaluated()) \
{ \
if constexpr (sizeof(pfx) > 1) \
std::fputs((pfx), stderr); \
+ std::fflush(stderr); \
FM_KILL_PRINTF_WARN_1() \
std::fprintf(stderr, __VA_ARGS__); \
FM_KILL_PRINTF_WARN_2() \