diff --git a/emper/Common.cpp b/emper/Common.cpp index a65097be02648b329eda3b52af2e313393f7768b..ec820e3f98df3c22d9d3058dae18169cace78009 100644 --- a/emper/Common.cpp +++ b/emper/Common.cpp @@ -10,7 +10,7 @@ void die(const char* message, bool usePerror) { if (usePerror) { std::perror(message); } else { - std::cout << message << std::endl; + std::cerr << message << std::endl; } exit(EXIT_FAILURE); } diff --git a/emper/Common.hpp b/emper/Common.hpp index fdda0ccfb80f50391047787b7d28816e8982fd19..72136a72e4a0ed1ba867112f22f7549dd876cfa6 100644 --- a/emper/Common.hpp +++ b/emper/Common.hpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright © 2020 Florian Schmaus +// Copyright © 2020-2021 Florian Schmaus, Florian Fischer #pragma once #include <functional> @@ -9,8 +9,16 @@ using func_t = std::function<void()>; #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define DIE die(__FILE__ ":" TOSTRING(__LINE__), false) -#define DIE_MSG(x) die(__FILE__ ":" TOSTRING(__LINE__) " " #x, false) -#define DIE_MSG_ERRNO(x) die(__FILE__ ":" TOSTRING(__LINE__) " " #x, true) + +// See Debug.hpp why we disable clang-format for the multi statement macro definitions +// clang-format off + +// NOLINTNEXTLINE(bugprone-macro-parentheses) +#define DIE_MSG(x) do { std::stringstream sst; sst << __FILE__ ":" TOSTRING(__LINE__) " " << x; die(sst.str().c_str(), false); } while (false) +// NOLINTNEXTLINE(bugprone-macro-parentheses) +#define DIE_MSG_ERRNO(x) do { std::stringstream sst; sst << __FILE__ ":" TOSTRING(__LINE__) " " << x; die(sst.str().c_str(), true); } while (false) + +// clang-format on // We compile with -fno-exceptions for the moment. //#define THROW(x) do { throw std::runtime_error(x); } while (false) diff --git a/emper/strategies/laws/LawsDispatcher.cpp b/emper/strategies/laws/LawsDispatcher.cpp index 94a82e7bc83562d6bfae8c0f3ffe767655316922..358494c9577c0129500e9e8f421cfd9e47077490 100644 --- a/emper/strategies/laws/LawsDispatcher.cpp +++ b/emper/strategies/laws/LawsDispatcher.cpp @@ -48,7 +48,7 @@ void LawsDispatcher::dispatchLoop() { lawsStrategy.dispatchedFiberFromAnywhere.fetch_add(1, std::memory_order_relaxed); break; default: - DIE_MSG("Unknown fiber flag: " << flag); + DIE_MSG("Unknown fiber source: " << next.metadata); break; } }