Exceptions on Openserver, Egcs 1.1.2-pre2
Dag Nygren
dag@newtech.fi
Mon Mar 1 02:45:00 GMT 1999
> > I need the MICO library and configure there gives me complaints about
> > exceptions not working with shared libraries....
>
> You'll just have to debug it. Product a minimal test case (and
> 'minimal' means a tiny self-contained bag of bytes that shows what MICO
> things is wrong, not an ftp site for it :-) and let us see what's going
> on.
OK, here we go. What is so wrong with this? (I am just learning C++,
but have some 15 years of C experience, so it is a real question, not
meant to provoke anyone.)
OS: Openserver 5.0.5 with /usr/ccs/bin/lef/ld "downgraded" to the original
5.0.5, the rest is rs505a upgraded
Compiler: EGCS 1.1.2-prerelease2 (2.91.62), with A.Montes' patch to make global
constructors work with shared libraries
Here are the files simplified from the MICO configure script :
===== lib.C =====
#include <iostream.h>
struct Global {
Global () { cout << "Constructing Global\n"; }
};
Global gbl;
#ifdef HAVE_EXCEPTIONS
class Ex {};
void bar ()
{
cout << "in bar\n";
throw Ex();
}
#endif
===== exception.C ======
extern "C" void exit(int);
class Ex {};
extern void bar ();
int main ()
{
try {
bar();
} catch (Ex &e) {
return 0;
} catch (...) {
return 1;
}
return 1;
}
And here is the script I used to compile them:
g++ -g -DHAVE_EXCEPTIONS -fPIC -c lib.C
g++ -g -shared -o libshex.so lib.o
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
g++ -g -o exception -L. -lshex exception.C
And here is my output:
dag:Ctest <ena> 744 % ./exception
Constructing Global
in bar
Abort
BRGDS
Dag
More information about the Gcc
mailing list