Fixed assertion name collision
This commit is contained in:
parent
2b3d9e6ef3
commit
6fc3e8c52b
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
int main(void){
|
||||
printf("\n\n");
|
||||
printf("Assertion sanity test.\n");
|
||||
ASSERT(NULL);
|
||||
ASSERTED(NULL);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user