   'Does not name a type' error
error: ‘player’ does not name a typeWhat is the meaning of this error? The code that is causing the error is the following:extern player player1;If the whole code of the project is needed, I can post it here. Please note that it is split into a number of header files.Thank you for your help in advance!   
  Contrary to many other error messages, this one is pretty clear; 'player' is not the name of a type. From that line, go back in the code, through included header files, and see where the player type is defined. You will find out that it is not defined before that line.   ;  The thing is, I AM including the player.h file (that contains the class 'player')   ;  Show us the complete contents of the file with the line extern player player1; in it and the complete contentes of player.h   ;Quote:Original post by pseudobotThe thing is, I AM including the player.h file (that contains the class 'player')Are you sure it's named player and not Player?   ;  ^Yep, no spelling mistakes or anything like that.The contents of ball.h (the one causing the error)#ifndef BALL_H#define BALL_H#include <cmath>#include "constants.h"#include "variables.h"#include "functions.h"#include "player.h"extern const int SCREEN_HEIGHT;extern const int SCREEN_WIDTH;extern const double FRICTION;extern const int BALL_MAXSPEED;extern const int BALL_HEIGHT;extern const int BALL_WIDTH;extern const int BALL_SPEED_INCREASE;extern const int BALL_MAXFRAME;extern const int BALL_BORDER;extern player player1;extern player player2;extern SDL_Surface *screen;SDL_Rect ballAnimRect[BALL_MAXFRAME];class ball {    private:   int X, Y;   int FRAME;    public:   ball(int, int, double, double);   double XVel, YVel;   double XPos, YPos;   bool hit;   void move();   void show();   void reset();   void collision();   void logic();   void setClips();};ball::ball(int X, int Y, double XSpeed, double YSpeed) {    XPos = X;    YPos = Y;    XVel = XSpeed;    YVel = YSpeed;    setClips();}void ball::show() {    //Trail    applySurface(X-(XVel*2), Y-(YVel*2), ballSurface, screen, &ballAnimRect[FRAME]);    //Ball    applySurface(X, Y, ballSurface, screen, &ballAnimRect[FRAME]);    FRAME = rand()%BALL_MAXFRAME;    applySurface(X, Y, ballSurface, screen, &ballAnimRect[FRAME]);}void ball::logic() {    move();    collision();}void ball::move() {    XPos += XVel;    YPos += YVel;    X = floor(XPos + .5);    Y = floor(YPos + .5);}void ball::collision() {    if (YPos < BALL_BORDER || YPos > SCREEN_HEIGHT - BALL_BORDER - (BALL_HEIGHT)) {   YPos -= YVel;   YVel = -YVel;    }    if (hitTest(X, Y, BALL_WIDTH, BALL_HEIGHT, player1.XPos, player1.YPos, PLAYER_BAT_WIDTH, PLAYER_BAT_HEIGHT) == true) {   YVel -= ((player1.YPos + (PLAYER_BAT_HEIGHT/2)) / 200);   hit = true;    }    if (hitTest(X, Y, BALL_WIDTH, BALL_HEIGHT, player2.XPos, player2.YPos, PLAYER_BAT_WIDTH, PLAYER_BAT_HEIGHT) == true) {   hit = true;    }    if (hit == true) {   hit = false;   XPos -= XVel;   XVel = -XVel;   if (XVel > 0) {  XVel += BALL_SPEED_INCREASE;   }   else {  XVel -= BALL_SPEED_INCREASE;   }   if (XVel > BALL_MAXSPEED) {  XVel = BALL_MAXSPEED;   }   else if (XVel < -BALL_MAXSPEED) {  XVel = -BALL_MAXSPEED;   }    }}void ball::setClips() {    for (int i = 0; i < BALL_MAXFRAME; i++) {   ballAnimRect.x = 50 * i;   ballAnimRect.y = 0;   ballAnimRect.w = 50;   ballAnimRect.h = 50;    }}#endifand player.h, that defines the player type:#ifndef PLAYER_H#define PLAYER_H#include <cmath>#include "constants.h"#include "variables.h"#include "functions.h"#include "ball.h"extern const int PLAYER_SPEED_MAX;extern const int PLAYER_SPEED_INCREASE;extern const int PLAYER_BAT_HEIGHT;extern const int PLAYER_BAT_WIDTH;extern const int PLAYER_MAXFRAME;extern const int SCREEN_HEIGHT;extern const int SCREEN_WIDTH;extern SDL_Surface *playerSurface;extern SDL_Surface *playerGlow;extern SDL_Surface *screen;extern SDL_Event SDLEvent;extern ball ball1;SDL_Rect pAnimRect[PLAYER_MAXFRAME];SDL_Rect pGlowAnimRect[5];class player {    private:   int X, Y;   int FRAME;    public:   player(int);   int playerType;   bool upPressed, downPressed;   double YVel;   double XPos, YPos;   void show();   void logic();   void handleInput();   void setClips();   void AI();};player::player(int X) {    FRAME = 0;    YPos = (SCREEN_HEIGHT / 2) - (PLAYER_BAT_HEIGHT/2);    XPos = X;    setClips();}void player::show() { //The glow    applySurface(X-20, Y-35, playerGlow, screen, &pGlowAnimRect[rand()%PLAYER_MAXFRAME]);    applySurface(X-20, Y-35-(YVel*4), playerGlow, screen, &pGlowAnimRect[rand()%PLAYER_MAXFRAME]);    applySurface(X, Y, playerSurface, screen, &pAnimRect[FRAME]);    FRAME = rand()%PLAYER_MAXFRAME;    applySurface(X+((rand()%2)-1), Y-(YVel*2), playerSurface, screen, &pAnimRect[FRAME]);    /*switch (playerType) {   case 1: applySurface(X, Y, p1, screen); break;   case 2: applySurface(X, Y, p2, screen); break;    }*/}void player::handleInput() {    if (SDLEvent.type == SDL_KEYDOWN) {   switch (SDLEvent.key.keysym.sym) {  case SDLK_UP: upPressed = true; break;  case SDLK_DOWN: downPressed = true; break;  default: break;   }    }    else if (SDLEvent.type == SDL_KEYUP) {   switch (SDLEvent.key.keysym.sym) {  case SDLK_UP: upPressed = false; break;  case SDLK_DOWN: downPressed = false; break;  default: break;   }    }}void player::logic() {    YVel *= (1-FRICTION);    if (upPressed == true) {   YVel -= PLAYER_SPEED_INCREASE;    }    if (downPressed == true) {   YVel += PLAYER_SPEED_INCREASE;    }    //Maxspeeds    if (YVel > PLAYER_SPEED_MAX) {   YVel = PLAYER_SPEED_MAX;    }    else if (YVel < -PLAYER_SPEED_MAX) {   YVel = -PLAYER_SPEED_MAX;    }    //The actuall moving    YPos += YVel;    Y = floor(YPos + .5);    X = floor(XPos + .5);}void player::setClips() {    //Animation rect of the bat    for (int i = 0; i < PLAYER_MAXFRAME; i++) {   pAnimRect.x = PLAYER_BAT_WIDTH * i;   pAnimRect.y = 0;   pAnimRect.w = PLAYER_BAT_WIDTH;   pAnimRect.h = PLAYER_BAT_HEIGHT;    }    //Animation rect of the glow    for (int i = 0; i < PLAYER_MAXFRAME; i++) {   pGlowAnimRect.x = 100*i;   pGlowAnimRect.y = 0;   pGlowAnimRect.w = 100;   pGlowAnimRect.h = 160;    }}void player::AI() {    if ((YPos + PLAYER_BAT_HEIGHT/2) < ball1.YPos-10) {   YVel += PLAYER_SPEED_INCREASE;    }    if ((YPos + PLAYER_BAT_HEIGHT/2) > ball1.YPos+10) {   YVel -= PLAYER_SPEED_INCREASE;    }}#endif;  Maybe you have a structure that has a circular dependency so the include guard drops it?// a.h#ifndef _H_A#define _H_A#include "b.h"class A{public:    // ect.    B b;};#endif// b.h#ifndef _H_B#define _H_B#include "a.h"class B{public:   // ect.   A a;};#endifThis won't compile. A needs B and B needs A ... but only one can come first.This can be solved by a foreward declaration. This can also be the case with your piece of code.The syntax for a foreward declaration is "class yourClassName;". Without the { } indicating the implementation.Edit: Using a foreward declaration in the example I gave does mean you have to change to a pointer, because you cannot allocate an object which is only declared.   ;  ^Yes, then that has to be the problem. I'll look into forward declaration then.Thanks for your help! [smile]   ;Quote:Original post by Dolf#define _H_AAccording to §17.6.3.3.2, you shouldn't do that:Quote:Each name that contains a double underscore _ _ or begins with an underscore followed by an uppercase letter (2.12) is reserved to the implementation for any use.Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.;  Wow awesome devfred, that's a major mistake on my part. That can kill cross-compiler compatibility I guess.I never knew that ... now I need to think of a new convention for include guards.What do you use?H_CLASSNAME ?CLASSNAME_H_?   