From 011d02cfcad1fdfa44fcb95c33a5e4b0f763ce35 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Fri, 29 May 2020 13:55:11 +0200 Subject: [PATCH] Add soft asserts and fixed precision in debug messages --- src/sfizz/Debug.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sfizz/Debug.h b/src/sfizz/Debug.h index f20d10a9..edafe597 100644 --- a/src/sfizz/Debug.h +++ b/src/sfizz/Debug.h @@ -8,7 +8,6 @@ #if !defined(NDEBUG) || defined(SFIZZ_ENABLE_RELEASE_ASSERT) #include -#include // Break in source code #if defined(_WIN32) && defined(_MSC_VER) @@ -40,16 +39,30 @@ ASSERTFALSE; \ } while (0) +#define CHECKFALSE \ + do { \ + std::cerr << "Check failed at " << __FILE__ << ":" << __LINE__ << '\n'; \ + } while (0) + +#define CHECK(expression) \ + do { \ + if (!(expression)) \ + CHECKFALSE; \ + } while (0) + #else // NDEBUG #define ASSERTFALSE do {} while (0) #define ASSERT(expression) do {} while (0) +#define CHECKFALSE do {} while (0) +#define CHECK(expression) do {} while (0) #endif // Debug message #if !defined(NDEBUG) || defined(SFIZZ_ENABLE_RELEASE_DBG) #include +#include #define DBG(ostream) do { std::cerr << std::fixed << std::setprecision(2) << ostream << '\n'; } while (0) #else #define DBG(ostream) do {} while (0)