11/09/2009

When I throw an exception, my program terminates with a “terminate called after throwing an instance of `…'” message

Answer

The function that throws the exception was called from C code, or code that was otherwise compiled without unwinding information. This affects gcc but not Visual C++: Visual C++ always generates full unwinding information.

If you can recompile the C code in question, recompile it with the –fexceptions flag: this will enable the generation of unwinding information (disabled by default for C).

If you cannot recompile the C code in question (for example, if it’s a system library), then you cannot throw exceptions when it calls your C++ code.

No comments:

Post a Comment