This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Need help with dynamic_cast across shared libraries with gcc 3.2.3.


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]