#include "exception.h" #include #include DEFINE_EXCEPTION(e1); DEFINE_EXCEPTION(e2); DEFINE_EXCEPTION(e0); static void usage(char *com) { fprintf(stderr,"usage : %s\n",com); exit(EXIT_FAILURE); } static void f1(int i); static void f2(int i); static void f3(int i); int main(int argc, char*argv[]) { if(argc != 2) usage(argv[0]); f1(atoi(argv[1])); fprintf(stderr, "terminaison normale de main\n"); return EXIT_SUCCESS; } void f1(int i) { HANDLE(e1, f2(i)); if (exception_raised()) fprintf(stderr,"exception e1 recuperee par f1 \n"); } void f2(int i) { HANDLE(e2, f3(i)); if (exception_raised()) fprintf(stderr,"exception e2 recuperee par f2 \n"); } void f3(int i) { switch(i % 4) { case 0: RAISE(e0); case 1 : RAISE(e1); case 2 : RAISE(e2); default: ; } }