This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Cannot catch exceptions thrown in a shared library under MS windows
- From: Rüdiger Ranft <_rdi_ at web dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 09 Nov 2007 12:30:46 +0100
- Subject: Cannot catch exceptions thrown in a shared library under MS windows
Hi all,
I got the problem that I can't catch an exception which is thrown in a
shared library under MS windows.
The compilers I tried were g++-4.1.2 and g++-4.2.2, running unter cygwin
with mingw32 target. The compilers where generated from vanilla sources,
configure paramters are "../gcc-4.2.2/configure --host=i686-pc-cygwin
--build=i686-pc-cygwin --target=i586-pc-mingw32
--enable-languages=c,c++" and "../gcc-4.1.2/configure
--build=i686-pc-cygwin --host=i686-pc-cygwin --target=i586-pc-mingw32
--enable-languages=c,c++" respectively.
In the wiki I found that this problem is a result of different
visibility models in gcc3 vs. gcc4, so I tried different compiler
switches (-fvisibility=default), but did not get any running configuration.
bye
Rudi
-8<---8<---8<---8<---8<-- cat th.cpp
#include <stdexcept>
void x() throw(std::runtime_error)
{
throw std::runtime_error("blubb");
}
-8<---8<---8<---8<---8<-- cat ct.cpp
#include <iostream>
extern void y();
int main()
{
y();
}
-8<---8<---8<---8<---8<-- a.cpp
#include <iostream>
#include <stdexcept>
extern void x()throw(std::runtime_error);
void y()
{
try
{
x();
}
catch(...)
{
std::cerr << "Exception\n";
}
}
-8<---8<---8<---8<---8<--
$ /usr/local/bin/i586-pc-mingw32-g++ -shared th.cpp -o th.dll
$ /usr/local/bin/i586-pc-mingw32-g++ -shared -o a.dll a.cpp th.dll
$ /usr/local/bin/i586-pc-mingw32-g++ -o ct.exe ct.cpp a.dll
$ ./ct.exe
abnormal program termination
terminate called after throwing an instance of 'std::runtime_error'
what(): blubb