help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic_cast problem


From: Ulrich Eckhardt
Subject: Re: dynamic_cast problem
Date: Sun, 04 Jul 2004 15:30:42 +0200
User-agent: KNode/0.7.6

KeithO wrote:
> The problem I am facing is not with dynamic loading of the library but
> with dynamic_cast. 

Firstly, it is really hard to guess what exactly you are referring to.
To-posting with a fullquote is not an acceptable style on the Usenet and
it it's plain stupid in this case.

However, there were some real errors pointed out to you, which you seem to
ignore. Fix those first.

> The test.app has retrieved a valid DestinationImpl *, I know 
> it's valid as I can call pDestImp->getName() which returns
> "Destination_tib". The problem comes when I try to dynamically cast to a
> Destination_tib *, which fails.
> Destination_tib * p = dynamic_cast<Destination_tib *>(pDestImpl);

There is one thing that might cause this: if dynamic_cast compares types by
looking at the address of the result of typeid(obj) and both the 'core'
part and the plugin have their own, private typeinifo objects, such a
comparison will fail.
Take a look at what 'typeid(*pDestImpl)' and 'typeid(Destination_tib)'
yield, maybe that will give you a hint.
 
> Interestingly if I compile the test.app with gcc rather than g++ I get
> the following link errors:
[errors]
> Why would it link with g++3 and not gcc3

That's nothing surprising, always use g++ to link C++ programms, as it
selects the proper core language support libs.

[trailing fullquote snipped]

Uli



reply via email to

[Prev in Thread] Current Thread [Next in Thread]