Re: Requirements for throwning C++ exceptions from one shared library to another in gcc 4.1.0?

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

 



Hi Glenn,

What platform?  IIRC, some platforms do not support throwing from one shared
library to another.

For example, as I recall, one platform that did not support throwing across
shared libraries was Sun Solaris.  (Maybe that's supported now.)

Linux, Darwin (OS X), Cygwin, MinGW support throwing across shared
libraries.

I don't recall about IBM AIX, HP-UX, or DEC Tru64.

Otherwise...

1. you must be using the same (preferably the *exact* same) g++ compiler for
both shared libraries.  g++ 3.2 for one and g++ 4.1 for the other won't
work, because the C++ ABI is slightly different.  Using g++ 4.0.1 for one,
and g++ 4.0.3 for the other... well, color me paranoid.  (I'm not entirely
certain which g++ versions have the same C++ ABI, and which have changed.
So to err on the side of paranoia, using the *exact* same version will
eliminate that variable.)

2. you either need default visibility, or if you use carte blanche hidden
visibility you must explicitly tag your classes used as exceptions, or used
in dynamic casting, or used in RTTI with
__attribute__((visibility("default"))), which allows the class's typeinfo to
be visible.  Otherwise the typeinfo compare won't match, since the weak
linkage of the typeinfo will be internal to the "package" (the shared object
library), and not coalesced via the magic of weak linkage to the same
typeinfo across all shared object libraries.

3. you must make sure you are not trying to throw an exception over a C
barrier.  That just won't work, since the stack won't have the EH unwinding
support, and your application will terminate posthaste.

4. I believe you can used shared libstdc++ (assuming your platform supports
throwing from one shared library to another).

5. (GUESS) using static libgcc with carte blanche hidden visibility may
cause grief.

6. Different C++ compilers, say MSVC++ and GCC's g++, do not have the same
C++ ABI at all, so they just won't work together.  Period.  If that's the
situation you are faced with, you have to have a C API edge (since,
fortunately, they have the same C ABI, since a given platform's C ABI is
usually well specified, on most platforms).

HTH,
--Eljay


[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