Cannot catch exceptions thrown in a shared library under MS windows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux