Archived

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

pdstatha

It's late ok!!!

Recommended Posts

I keep get an annoying error, now its probably really easy to solve but its late and I can''t think. d:\hardball\projectfiles\hardball\hardball.h(29) : error C2143: syntax error : missing '';'' before ''*'' d:\hardball\projectfiles\hardball\hardball.h(29) : error C2501: ''CPanel'' : missing storage-class or type specifiers d:\hardball\projectfiles\hardball\hardball.h(29) : error C2501: ''m_pPanel1'' : missing storage-class or type specifiers Which points to this section of code
  #ifndef HARDBALL_H
#define HARDBALL_H

#include "window.h"
#include "direct3d.h"
#include "panel.h"

#define SafeRelease(pInterface) if(pInterface != NULL) {pInterface->Release(); pInterface=NULL;}
#define SafeDelete(pObject) if(pObject != NULL) {delete pObject; pObject=NULL;}

class CHardball
{
  public:
	  CHardball();
	  virtual ~CHardball();
	  bool Init(CDirect3D* pD3DWindow,CWindow* pWindow,HINSTANCE hInstance);
	  CDirect3D* getD3D();
	  CWindow* getWindow();
	  void GameLoop();
  protected:	  
	  bool InitGame();
	  bool InitD3D();
	  void RenderText();
	  void Render2D();
	  void Render();
	  void Setup2DCamera();
	  CWindow* pWindow;
	  CDirect3D* pD3D;
	  CPanel* m_pPanel1;     //Here it is

	  DWORD m_dwFrames;
	  DWORD m_dwStartTime;
	  DWORD m_dwEndTime;
	  DWORD m_dwTotalPolygons;	
};

#endif  
I don''t understand since I am including panel.h where CPanel is defined, CPanel looks like this
  #ifndef PANEL_H
#define PANEL_H

#include "direct3d.h"
#include "hardball.h"
#include "window.h"

#define PANEL_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

class CPanel
{
  public:
	  CPanel(LPDIRECT3DDEVICE8 pD3DDevice, int nWidth, int nHeight, int nScreenWidth,
		      int nScreenHeight, DWORD dwColour = -1);
	  virtual ~CPanel();
	  bool setTexture(const char *szTextureFilePath, DWORD dwKeyColour = 0);
	  DWORD Render();
	  void moveTo(int x,int y);
  protected:
	  bool createVertices();
	  bool updateVertices();
	  LPDIRECT3DDEVICE8 m_pD3DDevice;
	  LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
	  LPDIRECT3DTEXTURE8 m_pTexture;
	  int iWidth;
	  int iHeight;
	  int iScreenWidth;
	  int iScreenHeight;
	  DWORD dwColour;
	  struct PANEL_CUSTOMVERTEX
	  {
		float x, y, z;		//Position of vertex

		DWORD colour;		//Colour of vertex

		float u, v;			//Texture coordinates

	  };
};

#endif  
[suttle hint] I''ve included the zipped project files should anyone be kind enough to take a look.[/suttle hint] And heres the link to the file http://www.cprogramming.com/cboard/attachment.php?s=&postid=146899

Share this post


Link to post
Share on other sites
Your problem is that panel.h is including hardball.h. Except hardball.h needs CPanel to be defined (it tries to include panel.h but the preprocessor definition will stop it from including) so therefore by the time the compiler gets to the definition of CPanel *m_pPanel1 CPanel hasn't been defined.

Here is one way to fix it:

use this as hardball.h

      
#ifndef HARDBALL_H
#define HARDBALL_H

#include "window.h"
#include "direct3d.h"

#define SafeRelease(pInterface) if(pInterface != NULL) {pInterface->Release(); pInterface=NULL;}
#define SafeDelete(pObject) if(pObject != NULL) {delete pObject; pObject=NULL;}

class CHardball
{
public:
CHardball();
virtual ~CHardball();
bool Init(CDirect3D* pD3DWindow,CWindow* pWindow,HINSTANCE hInstance);
CDirect3D* getD3D();
CWindow* getWindow();
void GameLoop();
protected:
bool InitGame();
bool InitD3D();
void RenderText();
void Render2D();
void Render();
void Setup2DCamera();
CWindow* pWindow;
CDirect3D* pD3D;
class CPanel * m_pPanel1;
DWORD m_dwFrames;
DWORD m_dwStartTime;
DWORD m_dwEndTime;
DWORD m_dwTotalPolygons;
};

#endif



and now panel.h

  
#include "direct3d.h"
#include "window.h"

#define PANEL_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)

class CPanel
{
public:
CPanel(LPDIRECT3DDEVICE8 pD3DDevice, int nWidth, int nHeight, int nScreenWidth,
int nScreenHeight, DWORD dwColour = -1);
virtual ~CPanel();
bool setTexture(const char *szTextureFilePath, DWORD dwKeyColour = 0);
DWORD Render();
void moveTo(int x,int y);
protected:
bool createVertices();
bool updateVertices();
LPDIRECT3DDEVICE8 m_pD3DDevice;
LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
LPDIRECT3DTEXTURE8 m_pTexture;
int iWidth;
int iHeight;
int iScreenWidth;
int iScreenHeight;
DWORD dwColour;
struct PANEL_CUSTOMVERTEX
{
float x, y, z; //Position of vertex

DWORD colour; //Colour of vertex

float u, v; //Texture coordinates

};
};

#endif



Now in hardball.cpp add
#include "panel.h"
just under the
#include "hardball.h"
and in panel.cpp add
#include "hardball.h"
just under the
#include "panel.h"

This should solve your problem hopefully

EDIT - Fixed the code above, and noticed another solution - if you don't want to do all of the above then just delete the #include "hardball.h" from the panel.h file and put it in panel.cpp instead



[edited by - Grambo on July 27, 2002 6:24:52 AM]

Share this post


Link to post
Share on other sites