Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Throwing exceptions across dynamic DLL boundaries on Linux

mcasale
Beginner
351 Views
Hello,
I am loading a DLL dynamically in which an exception of type E may be thrown from method M. In the try block in the main program, the type information for the exception appears to be lost. In other words, in the code
try{
M
} catch( E &e )
{
cout << "Caught an exception of type e" << endl;
}
catch(...)
{
cout << "Unknown exception" << endl;
}
M is in the dynamically loaded DLL with throws an exception of type E. But the catch block catch(E &e) is never entered: type info is lost. The catch(...) is entered. Is there any way around this?
Thanks very much,
Mac
0 Kudos
1 Reply
Otto_B_Intel
Employee
351 Views

Hi,

if you mean by dynamically loading a library you use dlopen then you have to use the flag RTLD_GLOBAL otherwise it will not load the exception information properly.

I hope this helps.

Otto

0 Kudos
Reply