The on_exception Function And -fno-exceptions Support

This library includes support for GCC's -fno-exceptions option. When a program is compiled with -fno-exceptions, it cannot use try, throw, or catch statements, and any error will result in a call to abort() unless otherwise dealt with. To activate this support, define the preprocessor macro BOOST_XINT_NO_EXCEPTIONS before including any Boost.XInt header.

To give your program a chance to at least record any error, and optionally recover from it using the setjmp/longjmp functions, the library includes an on_exception function. You call this function, passing in a function that you want called whenever there is a problem. The library will call that function and (if it returns) throw the exception as normal. (If BOOST_XINT_NO_EXCEPTIONS is used, it will call abort() after calling your function instead.)

Note that while setjmp/longjmp may allow you to recover from errors, it will often result in memory leaks since no destructors or other cleanup code is allowed to run.


© Copyright Chad Nelson, 2010-2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)