Made it redefine on each include
This commit is contained in:
parent
ff9264c2b2
commit
c8f0717d41
1 changed files with 15 additions and 7 deletions
|
@ -8,17 +8,25 @@
|
||||||
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
|
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
|
||||||
* The CWPL for more details.
|
* The CWPL for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASSERT_H
|
|
||||||
#define _ASSERT_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
#ifdef NDEBUG
|
||||||
#define assert(ignore) ((void) 0)
|
#define assert(ignore) ((void) 0)
|
||||||
#else
|
#else
|
||||||
#define assert(expression) (expression || (fprintf(stderr, "Assertion failed: %s: %d: %s", __FILE__, __LINE__, __func__) && abort()))
|
#define assert(expression) (expression || (fprintf(stderr, "Assertion failed: %s: %d: %s", __FILE__, __LINE__, __func__) && abort()))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue