weird includes // glGenTextures

M

Michael Sgier

Hello
in en.h i've:
#include "player.h"

if i do now include in player.h another header file:
#include "sod.h"

i get errors in en.h:
en.h:54: error: syntax error before `*' token
that's at this line:
public:
CPlayer *player; //here now the above error

if i do it like that in player.h:
//#include "sod.h"

there's no error. WHY? This looks weird to me.
All header files begin like this:
#ifndef __PLAYER_H
#define __PLAYER_H
same for all header. So ifndef __EN_H etc.

secondly, I'll post this also in a OpenGL newsgroup:
This, under Windows generates a new texID each time
it gets called but not under Linux. WHY? My model doesn't
get drawed and i guess because of that.

glGenTextures(1, &this->texID);

THANKS and regards
Michael
 
R

Rolf Magnus

Michael said:
Hello
in en.h i've:
#include "player.h"

if i do now include in player.h another header file:
#include "sod.h"

i get errors in en.h:
en.h:54: error: syntax error before `*' token
that's at this line:
public:
CPlayer *player; //here now the above error

if i do it like that in player.h:
//#include "sod.h"

there's no error. WHY?

This is a bit too short to give you an appropriate answer. Maybe, something
in your header is wrong, like a missing semicolon or something, and that
produces an error later in the other file.
All header files begin like this:
#ifndef __PLAYER_H
#define __PLAYER_H
same for all header. So ifndef __EN_H etc.

Those identifiers are reserved, like all that contain two consecutive
underscores.
secondly, I'll post this also in a OpenGL newsgroup:
This, under Windows generates a new texID each time
it gets called but not under Linux. WHY? My model doesn't
get drawed and i guess because of that.

If your model isn't drawn, it probably doesn't have to do with the texure.
What makes you think so?
glGenTextures(1, &this->texID);

Did you check for errors after that call?
 
G

Greg Comeau

in en.h i've:
#include "player.h"

if i do now include in player.h another header file:
#include "sod.h"

i get errors in en.h:
en.h:54: error: syntax error before `*' token
that's at this line:
public:
CPlayer *player; //here now the above error

if i do it like that in player.h:
//#include "sod.h"

there's no error. WHY? This looks weird to me.

Suspect (1) missing semicolon right before the public; or
(b) you're compiling as C instead of C++. If neither is so,
try to get the code into the smallest sample possible to
post here and hopefully in the process you'll detect
the problem yourself, if not, we'll have a look.
 
M

Michael Sgier

Hello again
so here's more code.
THANKS
Michael

player.h:

#ifndef __PLAYER_H
#define __PLAYER_H


//#include "ogro.h" // IF I INCLUDE ogro.h the error gets fired
#include "camera.h"
#include "object.h"
#include "terrain.h"
#include <typeinfo>


class CPlayer : public CObject

{
....
};

#endif




then the enemy.h:

#ifndef __ENEMY_H
#define __ENEMY_H


#include "entity.h"
#include "vector.h"
#include "player.h"
#include <typeinfo>

class CTerrain;

enum AIState_t
{
AI_UNCARING, // enemy is not scared and does not care
AI_SCARED, // enemy is scared and running away
AI_DEAD
};

class CEnemy : public CEntity
{
private:

protected:
int hitPoints; // hit points the enemy has left
float distFromPlayer; // distance this enemy is from player
float runSpeed; // speed of enemy when running
AIState_t aiState; // state of enemy thought

virtual void OnProcessAI() {}

void OnCollision(CObject *collisionObject)
{
// if this enemy collides with another enemy
if (typeid(*collisionObject) == typeid(CEnemy))
{
modelState = MODEL_IDLE;
velocity = CVector(0.0, 0.0, 0.0);
}
// if this enemy collides with the terrain (always)
else if (typeid(*collisionObject) == typeid(CTerrain))
{
position.y =
((CTerrain*)collisionObject)->GetHeight(position.x, position.z) + size;
}
else
{
}
}

public:
CPlayer *player; // HERE I GET THE ERROR IF I INCLUDE ogro.h in
player.h
....
};

#endif





and the ogro.h:

#ifndef __OGRO_H
#define __OGRO_H


#include "enemy.h"

class COgroEnemy : public CEnemy
{
....
};


#endif
 
J

Jim Langston

#include "player.h"
if i do now include in player.h another header file:
#include "sod.h"

i get errors in en.h:
en.h:54: error: syntax error before `*' token
that's at this line:
public:
CPlayer *player; //here now the above error

....

Michael Sgier said:
Hello again
so here's more code.
THANKS
Michael

player.h:

#ifndef __PLAYER_H
#define __PLAYER_H


//#include "ogro.h" // IF I INCLUDE ogro.h the error gets fired
#include "camera.h"
#include "object.h"
#include "terrain.h"
#include <typeinfo>


class CPlayer : public CObject

{
...
};

#endif

....

Simple. egro.h uses the CPlayer class, which isn't defined til AFTER ergo.h
is included.

At the top of ergo.h include the line:
class CPlayer;

and your problem should go away.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top