diff --git a/src/xdef.h b/src/xdef.h index 3ef8c85..1c7f4af 100644 --- a/src/xdef.h +++ b/src/xdef.h @@ -110,6 +110,25 @@ typedef uint8_t xbool_t; #define XLOCATION_LVL2(line) XLOCATION_LVL1(line) #define __XLOCATION__ XLOCATION_LVL2(__LINE__) +#ifdef _ASSERT_TIMED +#include +#define XTROW_LOCATION \ + { \ + char timeStr[20]; \ + time_t now = time(NULL); \ + struct tm *tmInfo = localtime(&now); \ + strftime(timeStr, sizeof(timeStr), \ + "%H:%M:%S.%03d", tmInfo ); \ + printf("%s %s%s " \ + "Assert failed: " \ + "%s:%s():%s\n", \ + XCLR_RED, XCLR_RES, \ + timeStr, \ + __FILE__, \ + __FUNCTION__, \ + __XLOCATION__); \ + } +#else #define XTROW_LOCATION \ printf("%s%s " \ "Assert failed: " \ @@ -118,6 +137,7 @@ typedef uint8_t xbool_t; __FILE__, \ __FUNCTION__, \ __XLOCATION__) +#endif #define XASSERT_RET(condition, value) \ if (!condition) return value