954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Syntax Error although there is none

I know, I know, this seems like an uber beginners question and most likely is. I have had this error several times and always figured it out myself, but this time it won't. GetUserData() returns a void*

#ifndef BLABLA_H
#define BLABLA_H
#include "GameEntity.h"

//class declaration left out for simplicity reasons

if (static_cast<GameEntity*>(point->shape1->GetUserData())->m_name == "player")
{

}
#endif;
error C2061: syntax error : identifier 'GameEntity'
error C2143: syntax error : missing ';' before '{'

Error occurs because of the cast to GameEntity, don't see why though. This should be perfectly O.K
Any help is appreciated, I'm stuck at this for way too long already!

IFEEL
Newbie Poster
6 posts since Apr 2009
Reputation Points: 46
Solved Threads: 0
 

> //class declaration left out for simplicity reasons
You mean you just deleted where the problem is, and decided just to post where the problem shows up.

Try again.

Oh, and while we're at it, remove this ;
#endif;

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Sorry, I did not think that the class declaration could cause the problem. b2ContactListener is just a class from the Box2D library with all virtual functions which I overwrite.

#ifndef CONTACT_LISTENER_H
#define CONTACT_LISTENER_H

#include "GameEntity.h"
#include <Windows.h>
#include <iostream>
#include <vector>

using std::cout;
using std::endl;

class CustomContactListener : public b2ContactListener
{
private:
	std::vector<ContactPoint> m_points;

public:
	virtual void Add(const b2ContactPoint* point)
	{
              if (static_cast<GameEntity*>(point->shape1->GetUserData())->m_name == "player")
              {

              }
         }
};
#endif
IFEEL
Newbie Poster
6 posts since Apr 2009
Reputation Points: 46
Solved Threads: 0
 

Alright, finally found the error. I used a namespace in some other file which caused a "syntax" error in the including class. Thx for the answer anyway. Anything that keeps me going is a help

IFEEL
Newbie Poster
6 posts since Apr 2009
Reputation Points: 46
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You