Next: , Previous: , Up: 2017   [Contents][Index]


New version of CCExceptions

Posted on Mon Feb 13, 2017

A new tag/tarball of one of my pet projects CCExceptions is available. Unsurprisingly, I had to make a backwards incompatible change in the API. While at it: I have reviewed the documentation. Once again I had to fix leftover errors from the last changes; there was also a lot of wrong terminology left there since even older changes. But this time everything is fine. Really!

This project provides a C11 language library implementing infrastructure for non–local exits on top of setjmp() and longjmp(); it makes use of some GCC extensions I want to experiment with.

Non–local exits, which are called exceptions in other languages, traditionally do not fit well with the C language: there is no standard built–in support for them like there is with the ever–evolving C++ language; the machinery to make them work is articulated. Full error handling is always articulated, no matter which mechanism we use; it is simple only in code examples in books and weblog posts.

The traditional way of C error handling with int error codes generates “specific” code: every function that inspects error codes and handles asynchronous resources allocation has its own logic that must be decoded by the human reader.

Using CCExceptions, the basic template code looks like this:

#include <ccexceptions.h>

cce_location_t  L[1];

if (cce_location(L)) {
  /* handler the error here */
  cce_run_error_handlers(L);
  cce_condition_free(cce_location_condition(L));
} else {
  /* do something useful here */
  cce_run_cleanup_handlers(L);
}

it is even more complex when we define error handlers. But the code looks always like this. This is what I am searching: an infrastructure that sacrifices a bit of speed and resources to obtain error handling code that always looks the same.

I dunno what will come out if this project, but this quest has been floating in my mind since a long time ago and I want to try it.


Next: , Previous: , Up: 2017   [Contents][Index]