From 9f0923f85d731892e7b58d959d93fdf3c0333096 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 25 Feb 2024 15:11:32 -0800 Subject: Better assert macro. --- cassert/include/cassert.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cassert/include/cassert.h b/cassert/include/cassert.h index 3349b55..e1c38d6 100644 --- a/cassert/include/cassert.h +++ b/cassert/include/cassert.h @@ -6,19 +6,19 @@ // Allow the client to define their own LOGE() macro. #ifndef LOGE #include -#define LOGE(...) \ - { \ - fprintf(stderr, "[ASSERT] %s:%d: ", __FILE__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ +#define LOGE(format, ...) \ + { \ + fprintf( \ + stderr, "[ASSERT] %s:%d " format "\n", __FILE__, \ + __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ } #endif // LOGE #define TRAP() raise(SIGTRAP) /// Unconditional hard assert. -#define FAIL(message) \ - LOGE(message); \ +#define FAIL(format, ...) \ + LOGE(format, __VA_ARGS__); \ TRAP(); /// Conditional hard assert. -- cgit v1.2.3