From c8f0717d415662334fcd0980f04bd7218baf49fb Mon Sep 17 00:00:00 2001 From: Kat Richey Date: Sat, 28 May 2022 13:17:40 -0500 Subject: [PATCH] Made it redefine on each include --- include/assert.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/include/assert.h b/include/assert.h index bcabb93..4e56e7a 100644 --- a/include/assert.h +++ b/include/assert.h @@ -8,17 +8,25 @@ * The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See * The CWPL for more details. */ - -#ifndef _ASSERT_H -#define _ASSERT_H - #include #include +/* + So, this one's a bit weird. Normally, we'd use include guards to make sure + a header is only included once, but the assert macro is supposed to be + redefined each time assert.h is included based on the current status of + NDEBUG, so we instead undefine-redefine assert and that's it. Technically, + it includes stdlib.h and stdio.h every time it's included, but meh. It's fine. + Those have include guards that mean it doesn't matter. + -Kat +*/ + +#ifdef assert +#undef assert +#endif + #ifdef NDEBUG #define assert(ignore) ((void) 0) #else #define assert(expression) (expression || (fprintf(stderr, "Assertion failed: %s: %d: %s", __FILE__, __LINE__, __func__) && abort())) -#endif - -#endif +#endif \ No newline at end of file