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
|
// External declarations
|
||||||
extern ExceptFrame *except_stack; // Global exception stack
|
extern ExceptFrame *except_stack; // Global exception stack
|
||||||
extern const Exception assert_failed; // Forward declaration for assert.
|
extern const Exception assert_failed; // Forward declaration for assert.
|
||||||
|
extern void asserted(int e);
|
||||||
|
|
||||||
#undef ASSERT
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define ASSERT(e) ((void)0)
|
#define ASSERTED(e) ((void)0)
|
||||||
#else
|
#else
|
||||||
extern void assert(int e);
|
#define ASSERTED(e) ((void)((e)||(RAISE(assert_failed),0)))
|
||||||
#define ASSERT(e) ((void)((e)||(RAISE(assert_failed),0)))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Raise an Exception.
|
// 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) {
|
void except_raise(const Exception *e, const char *file,int line) {
|
||||||
// An exception was raised, grab the exception stack.
|
// An exception was raised, grab the exception stack.
|
||||||
ExceptFrame *p = except_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
|
if (p == NULL) { // Uncaught Exception
|
||||||
const char *msg = e->reason ? e->reason : "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);
|
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.
|
// Jump to the saved context environment.
|
||||||
longjmp(p->env, EXCEPT_RAISED);
|
longjmp(p->env, EXCEPT_RAISED);
|
||||||
}
|
}
|
||||||
void (assert)(int e) {
|
void asserted(int e) {
|
||||||
ASSERT(e);
|
ASSERTED(e);
|
||||||
|
(void)e;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
int main(void){
|
int main(void){
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
printf("Assertion sanity test.\n");
|
printf("Assertion sanity test.\n");
|
||||||
ASSERT(NULL);
|
ASSERTED(NULL);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user