Add support for verbose asserts.

(cherry picked from commit 48e4c35fdc)
This commit is contained in:
Jonathan G Rennison
2016-09-05 01:18:09 +01:00
parent 51099c3572
commit 0b7d68a6d1
2 changed files with 23 additions and 0 deletions

View File

@@ -433,6 +433,7 @@ assert_compile(SIZE_MAX >= UINT32_MAX);
void NORETURN CDECL usererror(const char *str, ...) WARN_FORMAT(1, 2);
void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2);
void NORETURN CDECL assert_msg_error(int line, const char *file, const char *expr, const char *str, ...) WARN_FORMAT(4, 5);
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
/* For non-debug builds with assertions enabled use the special assertion handler:
@@ -447,6 +448,9 @@ void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2);
/* Asserts are enabled if NDEBUG isn't defined, or if we are using MSVC and WITH_ASSERT is defined. */
#if !defined(NDEBUG) || (defined(_MSC_VER) && defined(WITH_ASSERT))
#define OTTD_ASSERT
#define assert_msg(expression, ...) if (!(expression)) assert_msg_error(__LINE__, __FILE__, #expression, __VA_ARGS__);
#else
#define assert_msg(expression, ...)
#endif
#if defined(MORPHOS) || defined(__NDS__) || defined(__DJGPP__)