• Advertisement
Sign in to follow this  

Receiving very odd compiler Errors

This topic is 1334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So as the title states im receiving some odd errors with a couple of class that im working on. Im trying to implement the Entity Component System example from Game Programming Gems 6 and im getting a lot of issues with it from just doing test compiles every once in a while to check for syntax errors and such.

 

These classes are without definitions yet but I don't think that would be an issue.

#pragma once
#include <string>
#include <map>
#include "Component.h"

class GameObject
{
public:
	GameObject(const std::string GameObjectID);
	virtual ~GameObject()=0;

	const std::string GetID();
	void ClearComponents();

private:
	std::string mGameObjectID;
	std::map<const std::string, Component*> ComponentTable;
};


#pragma once
#include <string>
#include "GameObject.h"

class Component
{
public:
	Component();
	virtual ~Component()=0;

	virtual const std::string componentID() const = 0;

	virtual void Update();

	void SetOwner(GameObject* go);
	GameObject* GetOwner() const;

private:
	GameObject* mOwner;
};
Warning	4	warning C4183: 'GetOwner': missing return type; assumed to be a member function returning 'int'	c:\users\\code\c++\engine\engine\component.h	16	1	Engine
Error	3	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	c:\users\\code\c++\engine\engine\component.h	16	1	Engine
Error	6	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	c:\users\\code\c++\engine\engine\component.h	19	1	Engine
Error	9	error C2143: syntax error : missing ';' before '}'	c:\users\\code\c++\engine\engine\gameobject.h	18	1	Engine
Error	11	error C2143: syntax error : missing ';' before '}'	c:\users\\code\c++\engine\engine\component.h	20	1	Engine
Error	12	error C2143: syntax error : missing ';' before '}'	c:\users\\code\c++\engine\engine\component.cpp	12	1	Engine
Error	10	error C2143: syntax error : missing ';' before '{'	c:\users\\code\c++\engine\engine\component.h	6	1	Engine
Error	2	error C2143: syntax error : missing ';' before '*'	c:\users\\code\c++\engine\engine\component.h	16	1	Engine
Error	5	error C2143: syntax error : missing ';' before '*'	c:\users\\code\c++\engine\engine\component.h	19	1	Engine
Error	7	error C2065: 'Component' : undeclared identifier	c:\users\\code\c++\engine\engine\gameobject.h	17	1	Engine
Error	1	error C2061: syntax error : identifier 'GameObject'	c:\users\\code\c++\engine\engine\component.h	15	1	Engine
Error	8	error C2059: syntax error : '>'	c:\users\\code\c++\engine\engine\gameobject.h	17	1	Engine
Error	13	error C1004: unexpected end-of-file found	c:\users\\code\c++\engine\engine\component.cpp	12	1	Engine

Share this post


Link to post
Share on other sites
Advertisement

 

You've got circular inclusions for GameObject and Component.

 

Since you seem to only use pointers to each other remove the "#include "GameObject.h" from Component.h and vice versa. Add a forward declaration to each header.

...
class GameObject;
 
class Component
{
  ...

GameObject.h

...
class Component;
 
class GameObject
{
  ...

Seems to have done the trick and has given me one more C++ topic to research. Thank you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement