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
Master C and Embedded C Programming- Learn as you go A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another.
C does not have exception handling facilities. Errors are handled by examining the value returned by each function and signals (conditions reported to the program) are handled by using library functions.
The C programming language does not support exception handling nor error handling.
As such, C programming does not provide direct support for error handling but being a system programming language, it provides you access at lower level in the form of return values. Most of the C or even Unix function calls return -1 or NULL in case of any error and set an error code errno.
Here is one, compatible with C89 and implementing the try/catch/finally schema as can be found in other OO languages.
Symbian implemented exceptions (called 'leaves') in terms of longjmp. This was C++ code, but translatable to C. There's a previous post about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With