[ODE] Using exceptions to catch errors

Adam Paul Coates acoates at stanford.edu
Thu Aug 12 02:22:25 MST 2004


I've not been watching this thread until now, so maybe this has been
asked.  Does it make a difference that dError is linked as a C-style
function?  I'm not sure how the gcc linker handles this situation, but is
it possible that, to avoid throwing an exception to external C code, it
either allows execution to continue, or instead calls the global
unexpected() or terminate() functions (whose default behavior is to call
abort() I believe)?

A quick experiment might be in order to test this if it sounds reasonable.
You can install your own unexpected() and terminate() handlers via
set_unexpected() and set_terminate().

Hope that helps;  I'd be curious to know whether this is the reason.

Adam C.


> extern "C" void dError (int num, const char *msg, ...)
> {
>    va_list ap;
>    va_start (ap,msg);
>    if (error_function) error_function (num,msg,ap);
>    else printMessage (num,"ODE Error",msg,ap);
>    exit (1);
> }





More information about the ODE mailing list