Организация файлов в проекте Visual C ++ - PullRequest
0 голосов
/ 16 октября 2010

Я пишу проект в выпуске Visual C ++ 2010 Express. Все было хорошо, прежде чем я попытался добавить новый исходный файл в проект. Затем, когда я попытался включить один из файлов заголовков, компилятор сказал, что класс, объявленный в этом заголовке, не найден в другом исходном файле, который включает тот же файл заголовков.

Это вывод из сборки. Я добавил #pragma сообщение в каждый заголовочный файл, чтобы увидеть, когда оно будет включено.

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 ==========  

Ответы [ 2 ]

0 голосов
/ 16 октября 2010

Включили ли вы OSGFComponent.h и Game.h в заголовочный файл osgfdrawablecomponent.h ?

0 голосов
/ 16 октября 2010

Я полагаю, что заголовок, содержащий определение OSGFComponent, должен быть включен в osgfdrawablecomponent.h или OSGFComponentManager.cpp, прежде чем включать osgfdrawablecomponent.h

.
...