问题
I am rolling my own exception library for C and would like good examples to examine.
So far, I have been looking at David Hanson's: http://drhanson.net/work/
But I know I've seen other ones available in the past. Can you send me some additional pointers?
Thanks,
SetJmp
回答1:
Here is one, compatible with C89 and implementing the try/catch/finally schema as can be found in other OO languages.
回答2:
Symbian implemented exceptions (called 'leaves') in terms of longjmp. This was C++ code, but translatable to C. There's a previous post about this.
回答3:
Take a look at XXL: http://www.zork.org/xxl/
I found it quite usable in a previous project. Hasn't been updated in a while though.
回答4:
CException is simple exception handling in C. It is significantly faster than full-blown C++ exception handling but loses some flexibility. It is portable to any platform supporting setjmp/longjmp.
来源:https://stackoverflow.com/questions/1410329/exception-libraries-for-c-not-c