# HG changeset patch # User frosch # Date 2024-01-30 21:42:20 # Node ID 281cf7fd7f53f3c3f3db25a6ccab49b16aa34dbe # Parent 60ceb3bdd74c976fca24410968b1c46bcec020fd Codechange: wrap 'if' in macros into 'do { ... } while (false)', so it does not break on following 'else'. diff --git a/src/debug.h b/src/debug.h --- a/src/debug.h +++ b/src/debug.h @@ -34,7 +34,7 @@ * @param level The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown. * @param format_string The formatting string of the message. */ -#define Debug(category, level, format_string, ...) if ((level) == 0 || _debug_ ## category ## _level >= (level)) DebugPrint(#category, level, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)) +#define Debug(category, level, format_string, ...) do { if ((level) == 0 || _debug_ ## category ## _level >= (level)) DebugPrint(#category, level, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)); } while (false) void DebugPrint(const char *category, int level, const std::string &message); extern int _debug_driver_level; diff --git a/src/stdafx.h b/src/stdafx.h --- a/src/stdafx.h +++ b/src/stdafx.h @@ -392,7 +392,7 @@ void NORETURN AssertFailedError(int line /* For non-debug builds with assertions enabled use the special assertion handler. */ #if defined(NDEBUG) && defined(WITH_ASSERT) # undef assert -# define assert(expression) if (unlikely(!(expression))) AssertFailedError(__LINE__, __FILE__, #expression); +# define assert(expression) do { if (unlikely(!(expression))) AssertFailedError(__LINE__, __FILE__, #expression); } while (false) #endif /* Define JSON_ASSERT, which is used by nlohmann-json. Otherwise the header-file