#include #include #include "exception.h" #include "memory.h" #define K 1024 #define MEGA (K*K) DEFINE_EXCEPTION(e1); DEFINE_EXCEPTION(e2); static void loop(); static void f1(int); static void loop(void) { int i = 0; for(;;) { printf("loop : %d\n", i); HANDLE(e1, f1(i)); if (exception_raised()) printf("Exception e1 received in loop\n"); i++; } } static void f1(int i) { switch (i) { case 0: case 2: return; case 1: RAISE(e1); case 3: RAISE(e2); } } int main(void) { HANDLE(any, loop()); if (exception_raised()) printf("Exception received in main\n"); memory_alloc(1000*MEGA); return EXIT_SUCCESS; } /* loop : 0 loop : 1 Exception e1 received in loop loop : 2 loop : 3 Exception received in main Uncaught exception raised from "memory.c:18" */