Sign in to follow this  
beebs1

Exceptions

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this