shared libraries & exceptions
Nathan Myers
ncm-nospam@cantrip.org
Mon Feb 3 21:39:00 GMT 2003
On Fri, Jan 31, 2003 at 08:25:59PM -0600, Benjamin Kosnik wrote:
> On Fri, 31 Jan 2003 15:11:51 -0800
> Nathan Myers <ncm-nospam@cantrip.org> wrote:
>
> >... people often want to call exported C functions in C++ libraries
> >from (what are nominally) C programs. Is there any supported way to
> >explicitly initialize the g++ runtime machinery, in gcc-2 and/or in
> >gcc-3, e.g. by calling some reserved identifier at library-load time?
> >(I wouldn't expect the solution to be the same for gcc-2 and gcc-3.)
>
> You're a little vague on the exact problem description, or what you are
> trying to do.
I'm talking about plugins written in C++. No sensible person expects
to throw an exception out of a plugin, but everyone who writes a C++
plugin would like to wrap each C entry point in a try block. That
ought to work, except who has initialized the exception machinery to
make it work right? Not _main(), it was never run.
This isn't academic. I'm seeing segfaults during a throw of bad_alloc
in gcc-2.x, and know of no reason to think gcc-3 will necessarily do
any better.
So the question is, is there any (non-portable!) entry point that
can be called by the C code, before or after the dlopen, that will
ensure proper initialization of the exception apparatus?
Nathan Myers
ncm-nospam@cantrip.org
More information about the Libstdc++
mailing list