Add support for verbose asserts.

Use for test/exec DoCommand mismatches.
This commit is contained in:
Jonathan G Rennison
2016-02-16 18:27:21 +00:00
parent f86b5c58cb
commit 48e4c35fdc
4 changed files with 74 additions and 1 deletions

View File

@@ -446,6 +446,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:
@@ -460,6 +461,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__)