K
KKramsch
One of the features from other languages that I miss most in C is
trappable exceptions. More specifically, I think it's great to be
able to demarcate a whole block of code where several exceptions
can happen at various points, so that any one of these exceptions
can be trapped and handled by the exception-handling code collected
in one place after the block. This also means that the exception
generating code can be much cleaner, since all it has to do is
raise the exception locally and bomb. In contrast, in traditional
C programming, many, if not all, function calls have to be surrounded
by error-checking and error-handling code. The error checking can
easily overwhelm the code.
Is there any way to implement something like C++'s try/catch
mechanism for exception trapping in C?
Thanks!
Karl
trappable exceptions. More specifically, I think it's great to be
able to demarcate a whole block of code where several exceptions
can happen at various points, so that any one of these exceptions
can be trapped and handled by the exception-handling code collected
in one place after the block. This also means that the exception
generating code can be much cleaner, since all it has to do is
raise the exception locally and bomb. In contrast, in traditional
C programming, many, if not all, function calls have to be surrounded
by error-checking and error-handling code. The error checking can
easily overwhelm the code.
Is there any way to implement something like C++'s try/catch
mechanism for exception trapping in C?
Thanks!
Karl