By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

error C2143: syntax error : missing ';' before '*'

P: 4
Hi,

I'm doing a little game in OpenGL for college and I've got these 3 classes in C++:

WarBalls - represents the Game's Application. It is supposed to be a singleton and holds all the Game's Managers.
Expand|Select|Wrap|Line Numbers
  1. #ifndef WARBALLS_H
  2. #define WARBALLS_H
  3.  
  4. #include "cg/cg.h"
  5.  
  6. #include "ControllerManager.h"
  7. #include "CameraManager.h"
  8. #include "GameManager.h"
  9. #include "Light.h"
  10.  
  11. #include "NxPhysics.h"
  12. #include "ErrorStream.h"
  13.  
  14. namespace wbproject
  15. {
  16.     class WarBalls : public cg::Application    
  17.     {
  18.     private:
  19.         static WarBalls* instance;
  20.     protected:        
  21.         NxPhysicsSDK* _gPhysicsSDK;
  22.     public:        
  23.         WarBalls();
  24.         ~WarBalls();
  25.         static WarBalls* getInstance();
  26.         void createEntities();        
  27.         CameraManager* getCameraManager();
  28.         NxPhysicsSDK* getPhysics();
  29.     };
  30. }
  31.  
  32. #endif
  33.  
CameraManager - Manages which Camera to render.
Expand|Select|Wrap|Line Numbers
  1. #ifndef CAMMANAGER_H
  2. #define CAMMANAGER_H
  3.  
  4. #include "cg/cg.h"
  5. #include "FreeCam.h"
  6. #include "PanoCam.h"
  7. #include "FollowCam.h"
  8. #include "GameManager.h"
  9.  
  10. namespace wbproject{
  11.     class CameraManager :  public cg::Group,
  12.         public cg::GroupDraw,
  13.         public cg::GroupUpdate,
  14.         public cg::GroupReshapeEvent,
  15.         public cg::GroupMouseEvent
  16.     {    
  17.     protected:
  18.         void createEntities();
  19.         void postInit();
  20.     public:
  21.         CameraManager(std::string id);
  22.         ~CameraManager();        
  23.         void switchCamera(int activeCam);
  24.     };
  25. }
  26.  
  27. #endif
  28.  
  29.  
GameManager - Was created to manage the game's rules and state (and possibly, to command a future SceneManager)
Expand|Select|Wrap|Line Numbers
  1. #ifndef GAMEMANAGER_H
  2. #define GAMEMANAGER_H
  3.  
  4. #include "cg/cg.h"
  5. #include "Ball.h"
  6. #include "Box.h"
  7. #include "Force.h"
  8. #include "Level.h"
  9. #include "Wall.h"
  10.  
  11. #include "NxPhysics.h"
  12.  
  13. namespace wbproject{    
  14.     class GameManager : public cg::Group,
  15.         public cg::GroupDraw,
  16.         public cg::GroupUpdate
  17.     {
  18.     protected:
  19.         void createEntities();
  20.         void postInit();
  21.     public:
  22.         GameManager(std::string id);
  23.         ~GameManager();
  24.     };
  25. }
  26. #endif
  27.  
Also:
- I'm using VS 2008's VC++;
- the OpenGL libraries, GLU and GLUT are wrapped by a library provided by the teachers (that's the cg/cg.h);
- And the include of the "NXPhysics.h" is for the Nvidia's PhysX engine, but there is nothing implemented to use it yet;

Now, here is my problem:

I'm getting this error: "...\warballs.h(27) : error C2143: syntax error : missing ';' before '*'"

Everything was fine, until I had to "use" the GameManager inside the CameraManager class.
If i remove the "#include "GameManager.h"" from the CameraManager.h, the errors I get are those for not having the include (like "'GameManager' : undeclared identifier").

I tried to not "replicate" the "#include "GameManager.h"" removing it from the WarBalls.h (since I have the "ifndef's", should do just the same, right?), but nothing changed....

I found another post about the same error in which someone said to check the ";" after the end of the classes definition (double checked it, but no luck...)

This is the first time I'm working in C++ (I'm more used to Java), and this seems like something very simple, but that I'm not aware of in the including inner process of C/C++...



Thanks in advance.
Oct 30 '08 #1
Share this Question
Share on Google+
6 Replies


gpraghuram
Expert 100+
P: 1,275
I thik a ; is missing in the GameMnager.h before the endif(End of the namespace } )


Raghu
Oct 31 '08 #2

P: 4
I thik a ; is missing in the GameMnager.h before the endif(End of the namespace } )


Raghu
Thanks for your reply!

But, what you're saying would look anything like this? I tried it and the compiler continues to send the same error.
Expand|Select|Wrap|Line Numbers
  1. #ifndef GAMEMANAGER_H
  2. #define GAMEMANAGER_H
  3.  
  4. #include "cg/cg.h"
  5. #include "Ball.h"
  6. #include "Box.h"
  7. #include "Force.h"
  8. #include "Level.h"
  9. #include "Wall.h"
  10.  
  11. #include "NxPhysics.h"
  12.  
  13. namespace wbproject{    
  14.     class GameManager : public cg::Group,
  15.         public cg::GroupDraw,
  16.         public cg::GroupUpdate
  17.     {
  18.     (...)
  19.     };
  20. };
  21.  
  22. #endif
  23.  
Oct 31 '08 #3

100+
P: 687
What if you declare the same function outside the class? Outside the namespace ( with namespace:: qualifier )? In the same header file where the GamaManager is defined?
Oct 31 '08 #4

P: 4
What if you declare the same function outside the class? Outside the namespace ( with namespace:: qualifier )? In the same header file where the GamaManager is defined?
I think I can't, the function where I call the GameManager is the Manager's init event handler.

Expand|Select|Wrap|Line Numbers
  1.     void CameraManager::init(){        
  2.         ((FreeCam *)this->get("FreeCam"))->enable();
  3.         ((PanoCam *)this->get("PanoCam"))->disable();
  4.         ((FollowCam *)this->get("FollowCam"))->disable();
  5.  
  6.         GameManager* gm = ((GameManager *)cg::Registry::instance()->get("GameManager"));
  7.         Ball * b = (Ball *)gm->get("Ball");        
  8.         ((FollowCam *)this->get("FollowCam"))->followObject(b);
  9.  
  10.     }
  11.  
Oct 31 '08 #5

100+
P: 687
I think I can't, the function where I call the GameManager is the Manager's init event handler.
I said 'declare' - to check if compiler issue an error on the same function ( with the same or other name ) declared in other place.
Oct 31 '08 #6

P: 4
I said 'declare' - to check if compiler issue an error on the same function ( with the same or other name ) declared in other place.
I'm sorry, I didn't get it the first time.

I created another class

Expand|Select|Wrap|Line Numbers
  1. #ifndef TEST_H
  2. #define TEST_H
  3.  
  4. #include "cg/cg.h"
  5.  
  6. #include "CameraManager.h"
  7.  
  8. namespace wbproject2{    
  9.     class Test: public cg::Group,
  10.         public cg::GroupDraw,
  11.         public cg::GroupUpdate
  12.     {
  13.     protected:
  14.         void createEntities();
  15.         void postInit();
  16.     public:
  17.         Test(std::string id);
  18.         ~Test();
  19.         CameraManager* getCameraManager();
  20.     };
  21. }
  22.  
  23. #endif
  24.  
Commented the code in the WarBalls (in the cpp and h), but I'm getting the same error in this one.
Oct 31 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.