From a8b9d15d1bbe6925d7c93272786884ad05eca523 Mon Sep 17 00:00:00 2001 From: Peter Keresztes Schmidt Date: Sat, 29 May 2021 19:52:53 +0200 Subject: [PATCH] Utils: Add our own ASSERT macro Using `assert` from `` leads to unused variable warnings in release builds. Define the `ASSERT` macro which compiles to a no-op in release builds but still avoids the warnings. --- src/zm_font.h | 1 - src/zm_utils.h | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/zm_font.h b/src/zm_font.h index b606108b2..e1f03d7d1 100644 --- a/src/zm_font.h +++ b/src/zm_font.h @@ -20,7 +20,6 @@ #include "zm_define.h" #include -#include #include "span.hpp" #include #include diff --git a/src/zm_utils.h b/src/zm_utils.h index ea56f0b0b..87f9132eb 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -31,6 +31,14 @@ #include #include + +#ifdef NDEBUG +#define ASSERT(x) do { (void) sizeof(x); } while (0) +#else +#include +#define ASSERT(x) assert(x) +#endif + typedef std::vector StringVector; std::string Trim(const std::string &str, const std::string &char_set);