source: doc/working/exception/impl/main.cfa @ 7f18438

Last change on this file since 7f18438 was 88e0080, checked in by Andrew Beach <ajbeach@…>, 8 years ago

Added a file with notes about the new exception design.

  • Property mode set to 100644
File size: 510 bytes
Line 
1#include <stdio.h>
2#include "except.h"
3
4struct raii_t {
5        char * msg;
6};
7
8void ^?{}( type_raii_t * this ) {
9        printf("%s\n", this->msg);
10}
11
12void bar() {
13        raii_t a = { "Bar dtor" };
14
15        throw( 3 );
16}
17
18void foo() {
19        raii_t a = { "Foo dtor" };
20
21        try {
22                raii_t b = { "Foo try dtor" };
23
24                bar();
25
26                printf("Called bar successfully\n");
27        }
28        catch( 2 ) {
29                printf("Exception caught\n");
30        }
31
32        printf( "Foo exited normally\n" );
33}
34
35int main() {
36        raii_t a = { "Main dtor" };
37
38        foo();
39
40        printf("End of program reached\n");
41}
Note: See TracBrowser for help on using the repository browser.