Exceptions

Started by
0 comments, last by SiCrane 16 years, 2 months ago
Hiya, I'm using C++ exceptions in my current project, which consists of several DLLs. I read a few days ago that it's best not to let exceptions pass from the DLL to the EXE, as doing so can cause problems if different compilers were used for each. Is this correct? Thanks for any help [smile]
Advertisement
Different compiler's exception handling can be radically different. MSVC uses structured exception handling (SEH) as the underlying mechanism for its C++ exception implementation. GCC, on the other hand, uses setjmp/longjmp (SJLJ) to implement C++ exceptions on Win32. These two mechanisms share more or less nothing in common. Trying to catch a SEH exception with SJLJ won't work and vice versa; more importantly, stack unwind won't be detected from one to the other, so if you have a function compiled with MSVC called from a function compiled with GCC called from a function compiled with MSVC, and the first function throws, you may catch the exception, but leak the resources the GCC function allocated. This is not a good thing.

This topic is closed to new replies.

Advertisement