Need help with dynamic_cast across shared libraries with gcc 3.2.3.
Eljay Love-Jensen
eljay@adobe.com
Thu Jul 17 14:47:00 GMT 2003
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.
More information about the Gcc-help
mailing list