This is the mail archive of the
mailing list for the GCC project.
two questions about shared libraries and C++
- To: gcc at gcc dot gnu dot org
- Subject: two questions about shared libraries and C++
- From: Dale E Martin <dmartin at cliftonlabs dot com>
- Date: Thu, 4 Oct 2001 16:10:58 -0400
I had two questions about shared libraries in linux and g++. One I think
might just be a platform issue - the other might be but I'm not sure. I'm
using Debian Unstable - linux 2.4.9, g++ 2.95.4 pre-something, g++ 3.0.2
pre-something, and glibc 2.2.4.
The first question is about static data. Let's say I have static data
defined in a class. If I compile that class into a shared library, and
then get a handle out of the shared library to an instance of that class,
the static data is different than the data that I access in "main". I've
got a nice example of this if I'm not clear - I'm not sure about the policy
of attachments on this list. Is this a platform specific issue with linux
shared libraries, or is this a well defined behavior?
My other question is about multiple virtual inheritence and shared
libraries. If I define two pure virtual base classes "base1" and "base2",
and then I define a concrete class "concrete" virtually derived from these
base classes. I write a function that is accessed from a shared library
returning a void * that points at a "concrete".
In g++ 3.0 if I static cast this to one of the c++ base classes, it works
fine. If I then dynamic cast it to the other class, I get a null pointer
as if it wasn't derived from that base. If I static cast this same pointer
to the other base class, it's fine. Again, I can provide a simple example
of this "problem" in action if it's helpful.
In g++ 2.95.x the dynamic cast works. Is this a compiler issue, or a
platform issue? If either of these are platform issues, can someone
suggest who I can address them with?
Dale E. Martin, Clifton Labs, Inc.
Senior Computer Engineer
pgp key available