From 4848178cc7a81ec49afbbf7e8054a759104d5069 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 13 Apr 2021 15:18:37 +1000 Subject: [PATCH] debug/panic: use fmt for `unhandled` messages --- CMakeLists.txt | 4 ++-- debug/panic.hpp | 7 +++---- quaternion.cpp | 2 ++ version.cpp.rl | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b655994..18d02a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include (search_libs) find_package (PythonInterp 3 REQUIRED) find_package (RAGEL 6.9 REQUIRED) - +find_package (fmt REQUIRED) if (WIN32) # Enable features for Windows Vista and higher @@ -38,7 +38,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) ############################################################################### add_library(cruft) -target_link_libraries(cruft ${NC_CXX_STDCXXFS}) +target_link_libraries(cruft ${NC_CXX_STDCXXFS} fmt::fmt) # Setup a directory to hold built sources we may need to export to clients. diff --git a/debug/panic.hpp b/debug/panic.hpp index 4334469b..98519bb6 100644 --- a/debug/panic.hpp +++ b/debug/panic.hpp @@ -8,8 +8,9 @@ #pragma once +#include + #include -#include #include @@ -127,9 +128,7 @@ namespace cruft::debug::detail { if constexpr (std::is_enum_v) { unhandled (static_cast> (t)); } else { - std::ostringstream os; - os << "unhandled value: " << t << '\n'; - ::panic (os.str ()); + ::panic (fmt::format ("unhandled value: {}", t)); } } } diff --git a/quaternion.cpp b/quaternion.cpp index db7636b2..ab92d99e 100644 --- a/quaternion.cpp +++ b/quaternion.cpp @@ -13,6 +13,8 @@ #include "vector.hpp" #include "coord/ops.hpp" +#include + /////////////////////////////////////////////////////////////////////////////// using cruft::quaternion; diff --git a/version.cpp.rl b/version.cpp.rl index 8a07211e..6136ab90 100644 --- a/version.cpp.rl +++ b/version.cpp.rl @@ -8,12 +8,13 @@ #include "version.hpp" #include "maths.hpp" +#include "debug/assert.hpp" #include "debug/panic.hpp" -#include #include +#include -#include "debug/assert.hpp" +#include // We generate some really old style C code via ragel here, so we have to // disable some noisy warnings (doubly so given -Werror)