2010-10-16 7 views
0

Je suis en train d'écrire un projet dans Visual C++ 2010 Express Edition. Tout allait bien avant d'essayer d'ajouter un nouveau fichier source dans le projet. Puis quand j'ai essayé d'inclure l'un des fichiers d'en-tête, le compilateur a dit que la classe déclarée dans cet en-tête n'est pas trouvée dans un autre fichier source qui inclut le même fichier d'en-tête.Organisation de fichiers dans le projet Visual C++

Ceci est généré à partir de la construction. J'ai ajouté #pragma message dans chaque fichier d'en-tête pour voir quand il est inclus.

1>------ Build started: Project: OSGF, Configuration: Debug Win32 ------ 
1> OSGFComponentManager.cpp 
1>  OSGFComponentManager.h included 
1>  OSGFComponent.h included 
1>  Game.h included 
1>  GameTimer.h Included 
1>  ScreenText.h included 
1>  OSGFDrawableComponent.h icluded 
1>d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(7): error C2504: 'OSGFComponent' : base class undefined 
1>d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(10): error C2061: syntax error : identifier 'Game' 
1>d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(10): error C2065: 'game' : undeclared identifier 
1>d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(12): error C2614: 'OSGFDrawableComponent' : illegal member initialization: 'OSGFComponent' is not a base or member 
1>d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(16): error C2027: use of undefined type 'OSGFComponent' 
1>   d:\myprograms\osgf\osgf\osgfdrawablecomponent.h(4) : see declaration of 'OSGFComponent' 
1>d:\myprograms\osgf\osgf\screentext.h(11): error C2061: syntax error : identifier 'Game' 
1> Generating Code... 
1> Compiling... 
1> Main.cpp 
1>  Test.h included 
1>  Game.h included 
1>  GameTimer.h Included 
1>  ScreenText.h included 
1>  OSGFDrawableComponent.h icluded 
1>  OSGFComponent.h included 
1> Generating Code... 
1> Compiling... 
1> Test.cpp 
1>  Test.h included 
1>  Game.h included 
1>  GameTimer.h Included 
1>  ScreenText.h included 
1>  OSGFDrawableComponent.h icluded 
1>  OSGFComponent.h included 
1> Generating Code... 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

Répondre

0

Avez-vous inclus OSGFComponent.h et jeu. h dans le osgfdrawablecomponent.h fichier d'en-tête?

+0

Oui. Le code fonctionne correctement lorsque je supprime le fichier #include "OSGFComponentManager.h" de OSGFComponentManager.cpp. – Dani

+0

Comment cela fonctionne correctement, car vos déclarations sont dans le fichier d'en-tête (.h)? Ce n'est pas possible, si vous n'avez que l'implémentation dans le fichier cpp. Ou, OSGFComponentManager.h est inclus dans un autre fichier d'en-tête, inclus dans OSGFComponentManager.cpp? En outre, utilisez-vous les macros # ifdef- # define- # endif? –

+0

Je vous suggère de poster votre code ici, si ce n'est pas très long, parce que tout ce que nous pouvons faire est juste de tirer dans l'obscurité, sans voir que vous êtes la source. –

0

je suppose que l'en-tête contenant doit inclure la définition de OSGFComponent eigther dans osgfdrawablecomponent.h ou OSGFComponentManager.cpp avant, y compris osgfdrawablecomponent.h

+0

Il est inclus. – Dani

Questions connexes