I heard that throwing exceptions from / from the C ++ library can be potentially dangerous, especially with a DLL, and especially if the calling code and library are compiled with different compilers. Is there any truth to this? Is it safe if I stick with static libraries? Please note that I am not talking about the internal use of exceptions only in the library, I also want to throw them in the calling code :)
Just to clarify: Let's say I got a compiled static library that defines the Foo class as follows:
class Foo
{
public:
Foo()
{
if (stuffwentwrong)
throw(123);
}
};
And some guy uses it like this:
try
{
Foo foo_object;
}
catch (int i)
{
std::cout << "Oh bum. Code: " << i;
}
Would it be safe?
source
share