• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: dynamic_cast between modules
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic_cast between modules


  • Subject: Re: dynamic_cast between modules
  • From: Andreas Grosam <email@hidden>
  • Date: Thu, 4 Aug 2005 17:15:11 +0200


On 04.08.2005, at 15:09, Steve Baxter wrote:

Hi,

I'm trying to move a large project from Codewarrior to XCode. The project is broken down into around 50 modules, an application and a shared framework. The modules and app all link to the framework.

I am having two problems with typeinfo and dynamic_cast:

(1) In Codewarrior it was only necessary to include the header of a class to be able to use typeinfo or dynaamic_cast on that class. In XCode I get a link error - "Undefined symbols: typeinfo for xxxx". This is a pain - there are some circumstances where modules may pass data to each other through an object database. We use dynamic_cast to downcast the passed data safely.
If you cross DSO boundaries, for each class respectivley an object of that class which is an operand for typeid, dynamic_cast or used as paramter in a catch clause, you need to ensure that the class is "exported" - so that the RTTI symbols are visible from the other DSO.
There are already several mails in this list how to do this.



(2) I can get around (1) by including the cpp of the object in *both* modules rather than the "owning" module.
This is a hack.
This enables the modules to link, but now the RTTI information doesn't match!
I'm unsure whether this is supposed to work!

For instance, ModuleA and ModuleB both implement class Y which is a subclass of X.


ModuleA makes a Y object and puts it in the database.

ModuleB gets the object Y out of the database - the generic interface returns an X though, so a downcast is needed to cast X to Y.

The dynamic_cast fails - it seems that the object Y created by ModuleA is not considered to be of the same type as an object Y created by ModuleB.
Maybe because you created to identities of RTTI which are equal, but not the same. If the implementation of dynamic_cast assumes, that for each class only one, and only one instance of RTTI exists, then it might consider that two RTTI objects having different addresses are not equal. (if so, is this a bug in the compiler??)
Just an idea.



This is a bit of a showstopper for us - we rely on shared objects like this for our database to work!
Fortunately, you can easily fix this problem - just "export" the classes in question, means make the RTTI accessible from within another DSO.

One solution would be to put the implementations of all shared objects in the shared framework, however this bloats the shared framework which we are trying to avoid.
That wouldn't work, either.
When you have to call dynamic_cast, typeid or catch() from within another DSO, you need to export the classes.


Hope this helps.

Andreas


Anyone got any solutions for this? The ideal solution would be a fix for (1) so that the object code is only in one place.


Cheers,

Steve.

Stephen Baxter
Software Development Manager
Improvision
email@hidden
+44-2476-692229


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: dynamic_cast between modules
      • From: Steve Baxter <email@hidden>
References: 
 >dynamic_cast between modules (From: Steve Baxter <email@hidden>)

  • Prev by Date: CodeWarrior-style inline assembly help...
  • Next by Date: Re: 10.4 SDK does not support ZeroLink, disabling it.
  • Previous by thread: dynamic_cast between modules
  • Next by thread: Re: dynamic_cast between modules
  • Index(es):
    • Date
    • Thread