This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Need help with dynamic_cast across shared libraries with gcc 3.2.3.
- From: "Yuly Novikov" <novikov_yuly at hotmail dot com>
- To: eljay at adobe dot com, gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Cc: novikov_yuly at hotmail dot com
- Date: Thu, 17 Jul 2003 17:47:38 +0300
- Subject: Re: Need help with dynamic_cast across shared libraries with gcc 3.2.3.
- Bcc:
Unfortunately in the real code I use multiple inheritance + virtual
inheritance, so reinterpret_cast will return wrong pointer.
Any other ideas?
From: Eljay Love-Jensen <eljay@adobe.com>
To: "Yuly Novikov" <novikov_yuly@hotmail.com>, gcc@gcc.gnu.org,
gcc-help@gcc.gnu.org
CC: novikov_yuly@hotmail.com
Subject: Re: Need help with dynamic_cast across shared libraries with gcc
3.2.3.
Date: Thu, 17 Jul 2003 09:43:21 -0500
Hi Yuly,
>Is there any other way to make the algorithm above work with gcc 3.2.3?
If you KNOW the pointer is the given type, use a
reinterpret_cast<foo*>(ptr) instead of a dynamic_cast<foo*>(ptr). And put
a BIG disclaimer in your source code saying "This is correct. All your
{derived class pointer name} are belong to us."
Also note: if you use those kinds of objects for exceptions in your
across-shared-library boundaries, you'll probably run into situations where
your code fails to catch the object. The dynamic_cast mechanism uses the
same RTTI information that the exception handling's catch mechanism uses.
And, similiarly, you'll probably experience problems using the RTTI
mechanism if you use typeid and type_info.
HTH,
--Eljay
PS: you shouldn't need to dynamic_cast the derived pointer to the base
pointer type. A derived pointer IS-A base pointer, already.
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail