From 4d6091cc4efc51c70293cf4f9fbece96f88e0ee7 Mon Sep 17 00:00:00 2001 From: GroM Date: Wed, 28 Aug 2024 10:17:23 +0200 Subject: [PATCH] Fix assert macro (do not display full path name in release mode) --- src/assert.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/assert.h b/src/assert.h index 41e6d1ce..b0ef38a2 100644 --- a/src/assert.h +++ b/src/assert.h @@ -16,16 +16,14 @@ extern void assert(int cond, const char* msgStr); #define ASSERT_WITH_MSG(cond, msg) assert(cond, msg) -#define _MAX_ASSERT_LENGTH_ 25 -// Shortens a string literal by skipping some prefix -#define _SHORTEN_(strLiteral, size) \ - (sizeof(strLiteral) > size \ - ? (strLiteral) + sizeof(strLiteral) - size \ - : strLiteral \ - ) - #define _FILE_LINE_ __FILE__ ":" _TO_STR2_(__LINE__) -#define ASSERT(cond) assert((cond), _SHORTEN_( _FILE_LINE_, _MAX_ASSERT_LENGTH_)) +#define ASSERT(cond) \ + do { \ + if (!(cond)) { \ + PRINTF("ASSERT failed at "_FILE_LINE_"\n"); \ + } \ + assert((cond), NULL); \ + } while (0) #endif // H_CARDANO_APP_ASSERT