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!

Recommended Answers

All 3 Replies

> //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;

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

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

commented: Thanks for the update, can you now tick the "solved thread"? +36
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.