invalid use of incomplete type 'struct Ogre::ManualObject'

Get answers to all your basic programming questions. No Ogre questions, please!
tokumei
Gnoblar
Posts: 1
Joined: Wed Jun 20, 2012 7:47 am

invalid use of incomplete type 'struct Ogre::ManualObject'

Post by tokumei »

I'm working with this bit here:

Code: Select all

lWindow -> setAutoUpdated(false);
	{
		Ogre::ManualObject *lManualObject = NULL;
		{
			lManualObject = lScene -> createManualObject("CubeWithAxes");
			lManualObject -> setDynamic(false);
			
			float lSize = 0.7f;
			lManualObject -> begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
			{
				lManualObject -> triangle(0,1,2);
				lManualObject -> triangle(2,3,0);
				lManualObject -> triangle(4,6,5);
				lManualObject -> triangle(6,4,7);
			}
			lManualObject -> end();
		}
		Ogre::String lResourceGroup = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
		lManualObject -> convertToMesh("MeshCubeAndAxe");
	}
These are the errors that are returned whenever I try to compile:

Code: Select all

main.cpp: In function 'int main()':
main.cpp:67:18: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:70:18: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:72:19: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:73:19: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:74:19: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:75:19: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:77:18: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
main.cpp:80:17: error: invalid use of incomplete type 'struct Ogre::ManualObject'
/usr/include/OGRE/OgrePrerequisites.h:198:8: error: forward declaration of 'struct Ogre::ManualObject'
make: *** [main.o] Error 1
clang might be returning a bit more helpful list of errors:

Code: Select all

main.cpp:67:18: error: member access into incomplete type 'Ogre::ManualObject'
                        lManualObject -> setDynamic(false);
                                      ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:70:18: error: member access into incomplete type 'Ogre::ManualObject'
                        lManualObject -> begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT
                                      ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:72:19: error: member access into incomplete type 'Ogre::ManualObject'
                                lManualObject -> triangle(0,1,2);
                                              ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:73:19: error: member access into incomplete type 'Ogre::ManualObject'
                                lManualObject -> triangle(2,3,0);
                                              ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:74:19: error: member access into incomplete type 'Ogre::ManualObject'
                                lManualObject -> triangle(4,6,5);
                                              ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:75:19: error: member access into incomplete type 'Ogre::ManualObject'
                                lManualObject -> triangle(6,4,7);
                                              ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:77:18: error: member access into incomplete type 'Ogre::ManualObject'
                        lManualObject -> end();
                                      ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
              ^
main.cpp:80:17: error: member access into incomplete type 'Ogre::ManualObject'
                lManualObject -> convertToMesh("MeshCubeAndAxe");
                              ^
/usr/include/OGRE/OgrePrerequisites.h:198:8: note: forward declaration of 'Ogre::ManualObject'
        class ManualObject;
It seems like commenting out setDynamic and everything after it (while still being inside of the curly brace) seems to remove the errors. However, I need to use setDynamic because I want to manually set the geometry.

Thanks for any help!
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: invalid use of incomplete type 'struct Ogre::ManualObjec

Post by Klaim »

Simple: the header you included use forward declarations of ManualObject, so the compiler knows there is a type that is called like that, but it don't have it's full definition, only it's name.

You simply need to include OgreManualObject.h (if that's the correct header name).
Then the compiler will be able to use the type's member.

If you don't understand forward declaration, you should try to learn about it, it's very useful but it gets you in this kind of case easily too.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Re: invalid use of incomplete type 'struct Ogre::ManualObjec

Post by jacmoe »

And you need to include the ManualObject header in the implementation file, cpp.
Not in the header. (Because it nulls the advantage of forward declarations)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.