you may have to choose RTTI options on in settings.
It is not on by default in the environment.
I personally try to avoid using rtti, because of performance hit. you can
also get by with static_cast and reinterpret_cast, should you choose to...

vijay
----- Original Message -----
From: "mario.gonzalez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 27, 2002 5:30 AM
Subject: dynamic_cast on Grammar fails


> Hi,
>
> After a code review, we decided to change the line ("rootGrammar" is of
type "Grammar*"):
>
> SchemaGrammar* grammar = (SchemaGrammar*)rootGrammar;
>
> to:
>
> SchemaGrammar* grammar = dynamic_cast<SchemaGrammar*>(rootGrammar);
>
> As, we believe that using dynamic_cast (we're developing on the win32
platform, with vc6), is the most correct way to cast between types in the
same inheritance chain (we use dynamic_cast exclusively in our project).
>
> The only problem is that the latter method fails (whereas the former
method never failed), throwing an exception and returning 0, and yes, the
"Grammar" object we're trying to down-cast is fully initialized. The
compiler options are set to support RTTI, so I'm really failing to see
what's wrong here. The stack at the time of failure looks as follows:
>
> KERNEL32! 77e8f142()
> MSVCRTD! _CxxThrowException@8 + 57 bytes
> MSVCRTD! __RTDynamicCast + 383 bytes
> rfw::XMLPLCBuilder::createDataTypeMapping() line 335 + 23 bytes
>
> It is impossible to trace into the dynamic_cast, so it seems I'm left with
very few options on how to go about to fix this, or at least understand why
this fails. Has anybody else experienced this?
>
> Everything seems ok, the Grammar class is abstract, and seems to be a
polymorphic type, and no warnings or errors occur at compile-time.
>
> Any hints or tips are greatly appreciated
>
> Cheers
>
> Mario
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to