From 6fc3e8c52be6864d4b8605e091d4678345723f14 Mon Sep 17 00:00:00 2001 From: Randy Jordan Date: Fri, 4 Apr 2025 17:05:09 -0500 Subject: [PATCH] Fixed assertion name collision --- include/except.h | 7 +++---- src/except.c | 7 ++++--- tests/01_sanity.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/except.h b/include/except.h index 95c0846..3ccbf3a 100644 --- a/include/except.h +++ b/include/except.h @@ -25,13 +25,12 @@ void except_raise(const Exception *e, const char *file,int line); // Raise excep // External declarations extern ExceptFrame *except_stack; // Global exception stack extern const Exception assert_failed; // Forward declaration for assert. +extern void asserted(int e); -#undef ASSERT #ifdef NDEBUG -#define ASSERT(e) ((void)0) +#define ASSERTED(e) ((void)0) #else -extern void assert(int e); -#define ASSERT(e) ((void)((e)||(RAISE(assert_failed),0))) +#define ASSERTED(e) ((void)((e)||(RAISE(assert_failed),0))) #endif // Raise an Exception. diff --git a/src/except.c b/src/except.c index ba8a1d8..6d3c652 100644 --- a/src/except.c +++ b/src/except.c @@ -8,7 +8,7 @@ const Exception assert_failed = { "Assertion Failure!" }; // If ASSERT fails. void except_raise(const Exception *e, const char *file,int line) { // An exception was raised, grab the exception stack. ExceptFrame *p = except_stack; - assert(e != NULL); // Ensure exception pointer is not NULL + asserted(e != NULL); // Ensure exception pointer is not NULL if (p == NULL) { // Uncaught Exception const char *msg = e->reason ? e->reason : "Uncaught Exception!"; fprintf(stderr,"\033[31m%s | Address: 0x%p | Raised at %s@%d \033[0m" ,msg,(void *)e,file,line); @@ -24,6 +24,7 @@ void except_raise(const Exception *e, const char *file,int line) { // Jump to the saved context environment. longjmp(p->env, EXCEPT_RAISED); } -void (assert)(int e) { - ASSERT(e); +void asserted(int e) { + ASSERTED(e); + (void)e; } diff --git a/tests/01_sanity.c b/tests/01_sanity.c index 97b676b..907f0e3 100644 --- a/tests/01_sanity.c +++ b/tests/01_sanity.c @@ -7,7 +7,7 @@ int main(void){ printf("\n\n"); printf("Assertion sanity test.\n"); - ASSERT(NULL); + ASSERTED(NULL); return EXIT_SUCCESS; }