views:

390

answers:

3

Hoping some of you TinyXML++ people can help me out. Really, since you recomended to me before I think you owe me ;)

I have the following code:

   //ticpp::Iterator< ticpp::Element > child( "SetPiece" );
    ticpp::Iterator< ticpp::Node > child("SetPiece");
    GLuint lc_SPieces = 0;
    for(child = child.begin( this ); child != child.end(); child++ )
    {
        lc_SPieces++;
    }

If I use the top declaration for child I get the error:

Unhandled exception at 0x7c812aeb in Drawing.exe: Microsoft C++ exception: __non_rtti_object @ 0x0012f7b4.

And I get it in dbgheap.c at this line:

pvBlk = _heap_alloc_dbg(nSize, nBlockUse, szFileName, nLine);

What's weird is it works with Node, and I know that there are elements in there(I checked using the TinyXML iteration methods).

Has anyone run into this before?

+1  A: 

just poking in the dark, i don't know tinyxml, but it seems that a dynamic_cast went wrong. If you dynamic_cast<> a pointer, you get a NULL-pointer on failure. However, if you cast to a reference type, there is no concept of a NULL-reference, so the runtime throws this exception (or bad_type). MSDN on dynamic_cast, and why it can go wrong

The line you pasted for the exception to occur does not help to clear up the situation, since it identifies the symptom rather than the cause.

Try to identify the cast that went wrong, you should be able to find it if you walk up the stack and find the last method in tinyxml libs or headers. Then you can decide whether tinyxml is worng, or you just applied it the wrong way.

good luck!

tabdamage
A: 

Project -> Properties -> C/C++ -> Language -> Enable Run-Time Type Info

fizzer
+1  A: 

__non_rtti_object is generated by the dynamic_cast operator if the passed pointer or reference does not point to a polymorphic object, but to some garbage instead. Maybe the object had been deleted earlier.

Step through the code in the debugger and check where the dynamic_cast is used and what is passed to it.

hth Paavo

paavo256