aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-02-25 15:11:32 -0800
committer3gg <3gg@shellblade.net>2024-02-25 15:11:32 -0800
commit9f0923f85d731892e7b58d959d93fdf3c0333096 (patch)
treeb43230530245df0f6ade155edb38683533617a6c
parentd666c271bec412d700298200dbff22102c2bdd63 (diff)
Better assert macro.
-rw-r--r--cassert/include/cassert.h14
1 files 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 @@
6// Allow the client to define their own LOGE() macro. 6// Allow the client to define their own LOGE() macro.
7#ifndef LOGE 7#ifndef LOGE
8#include <stdio.h> 8#include <stdio.h>
9#define LOGE(...) \ 9#define LOGE(format, ...) \
10 { \ 10 { \
11 fprintf(stderr, "[ASSERT] %s:%d: ", __FILE__, __LINE__); \ 11 fprintf( \
12 fprintf(stderr, __VA_ARGS__); \ 12 stderr, "[ASSERT] %s:%d " format "\n", __FILE__, \
13 fprintf(stderr, "\n"); \ 13 __LINE__ __VA_OPT__(, ) __VA_ARGS__); \
14 } 14 }
15#endif // LOGE 15#endif // LOGE
16 16
17#define TRAP() raise(SIGTRAP) 17#define TRAP() raise(SIGTRAP)
18 18
19/// Unconditional hard assert. 19/// Unconditional hard assert.
20#define FAIL(message) \ 20#define FAIL(format, ...) \
21 LOGE(message); \ 21 LOGE(format, __VA_ARGS__); \
22 TRAP(); 22 TRAP();
23 23
24/// Conditional hard assert. 24/// Conditional hard assert.