Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ekim_Gram

I need help with an error that I can't seem to fix

This topic is 5315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, my current project right now is a 2D side scrolling shooter called "Space Blasters". I have a few classes but I'm having trouble with my Ship class. I've got Ship.h and Ship.cpp and then Common.h/cpp for all the globals in my game. Common.h:
// Common.h


#ifndef COMMON_H
#define COMMON_H

#include <sdl.h>

#include "Bullet.h"
#include "Enemy.h"
#include "Font.h"
#include "Ship.h"

//////////// GAME GLOBALS ///////////

extern Enemy  g_Enemies;
extern Ship   g_Ship;

extern SDL_Surface * g_GameScreen;		// The game screen surface

extern SDL_Surface * g_Background;		// The background image


#endif  COMMON_H
Common.cpp:
// Common.cpp


#include "Common.h"

Bullet g_Bullets;
Enemy  g_Enemies;
Ship   g_Ship;

SDL_Surface * g_GameScreen;		// The game screen surface

SDL_Surface * g_Background;		// The background image

Right now, I'm getting two errors in Common.cpp. They are as follow:
Space Blasters\Common.h(15) : error C2146: syntax error : missing ';' before identifier 'g_Ship'

Space Blasters\Common.h(15) : error C2501: 'g_Ship' : missing storage-class or type specifiers
  
Line 15 in Common.h reads:
 extern Ship g_Ship;  
I don't understand. This always seems to happen when I do stuff like this.[/source]
R.I.P. Mark Osback Solo Pa Mi Gente VG-Force Ekim Gram Productions [edited by - Ekim_Gram on February 29, 2004 5:16:58 PM] [edited by - Ekim_Gram on February 29, 2004 5:17:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
Nope, didn''t forget semicolon. Here''s Ship.h


// Ship.h


#ifndef SHIP_H
#define SHIP_H

#include "Common.h"

class Ship
{
public:

void DrawShip(); // Draw''s the ship onto the screen


int m_Lives; // Number of lives the player has

int m_Score; // The player''s score


bool m_Respawn; // Did the player just respawn?


CSprite m_Sprite; // Base sprite image

CSprite m_Base; // Handles animations and such


};
#endif SHIP_H




R.I.P. Mark Osback
Solo Pa Mi Gente
VG-Force
Ekim Gram Productions

Share this post


Link to post
Share on other sites
Common.h is included before the definintion in ship.h. To fix it, add ''class Ship;'' to ship.h before you include common.h.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!