|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-21 13:27:07
Hi Everyone,
In the work I'm doing on Boost.Python I am running into some issues that are
outside the standard. I'm trying to figure out what I can rely on with
respect to RTTI when shared objects are linked together. The problem goes
something like this:
Each Python extension module is a separate shared library/DLL. Each such
module is going to register some information about the types it wraps with a
central shared object. That way, module A can expose class A which uses
class B, which is exposed by module B.
In general, it would be best to avoid having to dynamically link A and B to
one another. I think that in general this is possible as long as A isn't
trying to dynamic_cast the B object it receives to some related class. This
is kind of hairy, I know, because A and B are likely to have duplicate
vtable information, etc... but few vendors have information on what is
really required in order to share types across shared libraries.
I have enclosed a small project that can be built and tested with
jam -sBOOST_ROOT=<boost installation> -sTOOLS="<toolsets>"
This project does a few small experiments with typeid() and exceptions
across modules which are not explicitly linked together. I have tried it
with msvc, gcc, metrowerks, and Borland on Win32.
metrowerks and msvc gave the same results: everything the tests try work as
you would like.
gcc was only able to compare typeinfo objects successfully if they were from
the same shared object, but it could identify them correctly by the
type_info::name(). It can call virtual functions across modules that aren't
linked together, but an exception thrown from such a call spells disaster.
Borland is really strange: it refuses to link if the virtual functions in
y.hpp aren't defined inline, but even if they are, it silently fails to
generate an executable that can be run! I'd appreciate it if some Borland
expert could take a look at the command line and tell me if there's
something wrong with it.
I'd also appreciate any data others can give me about their favorite
compilers.
Thanks,
Dave
===================================================
David Abrahams, C++ library designer for hire
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk