0

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!

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by IFEEL
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;

0

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
1

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

Votes + Comments
Thanks for the update, can you now tick the "solved thread"?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.