
"Emil Dotchevski" <emildotchevski@gmail.com> wrote in message news:AANLkTimer-e0pFMq977OQWGwCanBZQWGm-8FK8uKBNvr@mail.gmail.com...
On Mon, Dec 6, 2010 at 3:10 PM, Edd Dawson <lists@mr-edd.co.uk> wrote:
Looking again at the JPEG code here. As far as I can tell setjmp/longjmp have been used with appropriate care, but I worry what will happen if a method on a Device throws an exception, for example. I've had both Visual C++ 2008 and Apple's g++ 4.0.1 crash on me in this kind of situation.
Did you use -fexceptions with GCC, and if I'm not mistaken MSVC also has an option to assume that C functions don't throw exceptions, which shouldn't be used for exceptions to work.
Exceptions work just fine without /EHs (at least with MSVC, which also defaults to extern C=nothrow)...or did you mean in this particular case (throwing through a C lib)? Either way, compiling the entire binary with "extern C exceptions" is an overkill...it is enough to wrap the affected functions in wrappers properly decorated with "throw (...)"...and in addition, depending on how C++ exceptions are implemented on a particular platform, it may be needed to recompile the C lib with C++ exception support enabled (no necessary with MSVC for example)... -- "What Huxley teaches is that in the age of advanced technology, spiritual devastation is more likely to come from an enemy with a smiling face than from one whose countenance exudes suspicion and hate." Neil Postman