Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception handling library in pure C

Tags:

c

exception

Is there some crossplatform c-library for exception handling (to implement try / catch in C)?

I'm also looking for documentation how it's realized in c++ (how the interrupts are masking or something like this)

like image 806
qmor Avatar asked Dec 21 '22 08:12

qmor


1 Answers

You can try exceptions4c; it's an exception handling library in ANSI C that supports: throw, try, catch, finally and a few more goodies. For example, it supports the Dispose pattern, so you can automatically release resources. You can also handle signals (such as SIGFPE and SIGSEGV) as if they were exceptions.

It's implemented on top of setjmp and longjmp (standard C library), and it's free software, so you can read and modify the source code.

Oh, by the way, I'm the author :) Please take a look at it, and compare it against other alternatives to see which fits you most.

like image 99
Guillermo Calvo Avatar answered Dec 24 '22 02:12

Guillermo Calvo