From 8f24fd992e39fdd91cad06c69d01e4561d8bf419 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Mar 2024 19:18:04 +0100 Subject: compat/assert: try harder to flush std{out,err} --- compat/assert.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'compat') 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 -#include -#include +#include // todo speed up loading by moving printing into a .cpp file +#include // 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() \ -- cgit v1.2.3