celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Broekhuis <a.broekh...@gmail.com>
Subject Exception Handling in C
Date Sun, 13 Feb 2011 12:36:24 GMT
Hello everyone,

Now that everything is in SVN, I would like to start working on the code again.

There is one important aspect which still needs a solution: Exception handling
Celix follows the OSGi spec (Java), but since C doesn't have
exceptions like Java, a solution is needed to be able to report

I've been looking on the web, and found 2 possible solutions.

1) Using a library that uses setjmp/longjmp:
Examples are:
- http://libexcept.sourceforge.net/
- http://www.nicemice.net/cexcept/
- http://code.google.com/p/exceptions4c/

2) Use the return value of functions:
- For example by simply returning a int value indicating the error
- Use a library which supplies try/catch macros: http://code.google.com/p/libex/

The first solution makes it possible to have an API very similar to
the OSGi spec, but I am not sure how setjmp and longjmp interact with
threads and real time behavior.
The second solution is the most simple, and with the help of a library
it is still possible to have clear code with try/catch constructs.

Does anyone have any experience with these kind of libraries?

For now I tend to lean towards using a simple solution, either simply
returning the error code, or using something like libex (which is
lgpl, which might be a problem..).

Kind regards,

Alexander Broekhuis

View raw message