Changeset - r28622:281cf7fd7f53
[Not reviewed]
master
0 2 0
frosch - 9 months ago 2024-01-30 21:42:20
frosch@openttd.org
Codechange: wrap 'if' in macros into 'do { ... } while (false)', so it does not break on following 'else'.
2 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/debug.h
Show inline comments
 
@@ -31,13 +31,13 @@
 
/**
 
 * Ouptut a line of debugging information.
 
 * @param category The category of debug information.
 
 * @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;
 
extern int _debug_grf_level;
 
extern int _debug_map_level;
 
extern int _debug_misc_level;
src/stdafx.h
Show inline comments
 
@@ -389,13 +389,13 @@ void NORETURN NotReachedError(int line, 
 
void NORETURN AssertFailedError(int line, const char *file, const char *expression);
 
#define NOT_REACHED() NotReachedError(__LINE__, __FILE__)
 

	
 
/* 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
 
 * will re-include assert.h, and reset the assert macro. */
 
#define JSON_ASSERT(x) assert(x)
 

	
0 comments (0 inline, 0 general)