The type in a dynamic_cast must be a pointer or reference to a complete class type, or void *

14,526

I believe you have to #include the header file which contains the body of class osg::PositionAttitudeTransform.
dynamic_cast gives such error when the body of the destination class is not visible.

Here is the similar error reproduced in g++.

Share:
14,526
Kobojunkie
Author by

Kobojunkie

I am a dedicated Developer at heart coding and pushing my way to becoming a master. Would really appreciate if you those who are not willing to share their knowledge, without question, avoid even posting a responses to questions asked. Some of us are here to learn from those who have know.

Updated on June 07, 2022

Comments

  • Kobojunkie
    Kobojunkie about 2 years

    I am hoping there is someone out there who understands why the code below fails. I am trying to get an instance of PositionAttitudeTransform (Openscenegraph class) from an osg::Node* node object. But there is the compiler error below in bold.

     void CameraPosCallbackUpdate::operator()(osg::Node* node, osg::NodeVisitor* nv)
    { 
       // other code goes here
    
        osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*> (node);
    
    }
    

    IntelliSense: the type in a dynamic_cast must be a pointer or reference to a complete class type, or void *

    Please help me with correct way to access my object and I would appreciate help in understanding what the problem here is since I believe the cast should be possible.

    Hierarchy http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00529.html

    • Alok Save
      Alok Save over 11 years
      You need to show the declaration of node. As the error message says, it should be a pointer or reference to a complete type.
    • Kobojunkie
      Kobojunkie over 11 years
      code updated with more detail on where node is coming from.
    • Luc Danton
      Luc Danton over 11 years
      Is the type, in fact, complete? Is a definition for it visible from here?
    • Denis Ermolin
      Denis Ermolin over 11 years
      As compiler said to you you have not included osg::PositionAttitudeTransform implementation
  • Kobojunkie
    Kobojunkie over 11 years
    Thank you. I had to remove the #include <osg/Transform> and replaced it with #include <osg/PositionAttitudeTransform>.