Skip to content

Commit

Permalink
ST: Add exceptions examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 16, 2024
1 parent e5ee496 commit a8513c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions trunk/research/st/exceptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
# !!! ST does not support C++ exceptions on cygwin !!!
g++ exceptions.cpp ../../objs/st/libst.a -g -O0 -o exceptions && ./exceptions
*/
#include <stdio.h>
#include <exception>
#include "../../objs/st/st.h"

int handle_exception() {
try {
throw 3;
} catch (...) {
return 5;
}
}

void* foo(void* arg) {
int r0 = handle_exception();
printf("r0=%d\n", r0);
return NULL;
}

int main(int argc, char** argv) {
st_init();
st_thread_create(foo, NULL, 0, 0);
st_thread_exit(NULL);
return 0;
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Directly compile c++ source and execute:
g++ win-thread.cpp ../../objs/st/libst.a -g -O0 -o win-thread && ./win-thread
g++ threads.cpp ../../objs/st/libst.a -g -O0 -o threads && ./threads
*/
#include <stdio.h>
#include <pthread.h>
Expand Down

0 comments on commit a8513c9

Please sign in to comment.