Removed double NAME entry.
[AROS.git] / test / cplusplus / exception.cpp
blobe8ca18ea923b68e4e7dd01818c2bdea7bf0ffb1d
1 /*
2 * We use printf() here instead of C++ traditional cout because linking in cout
3 * increases executable size up to 3 megabytes (!!!), making it difficult to
4 * disassemble it. Anyway our aim is to test exceptions.
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
10 #ifdef __AROS__
12 #include <exec/alerts.h>
13 #include <proto/exec.h>
15 extern void *__eh_frame_start;
18 * Non-working call frame unwinding in AROS causes calling abort().
19 * Here we manually override this function to call Alert(),
20 * which can give us a stack trace.
22 void abort(void)
24 printf("abort() called\n");
26 Alert(AN_Unknown);
28 /* Calling exit here makes this a noreturn function
29 * avoiding a compiler warning. */
30 exit(20);
33 #endif
35 /* Just to make things a little bit more complex. */
36 int sub()
38 printf("sub() entered\n");
40 throw 20;
43 int main ()
45 #ifdef __AROS__
46 printf("Exception frames start at %p\n", &__eh_frame_start);
47 #endif
49 try
51 sub();
53 catch (int e)
55 printf("An exception occurred. Exception Nr. %d\n", e);
58 printf("Exiting\n");
59 return 0;