2012-07-03 3 views
0

이렇게 분명히 실제 오류가 아니지만 증상이 매우 모호하기 때문에 실제 오류가 무엇인지 전혀 알지 못합니다. 여기에 파일을 포함 시키겠다. 너희들은 어디서 무엇을 믿을 지 몰랐다.오류 c2056 : 선언되지 않은 식별자

system.h(66): error C2065: 'EntityManager' : undeclared identifier

system.h

/******************************************************************************* 
filename: System.h 

Author: 

Date: November 13, 2010 

********************************************************************************/ 


#ifndef SYSTEM_H 
#define SYSTEM_H 

#include <string> 
#include <memory> 

//The interfaces for the framework elements. 
#include "I_OS.h" 
#include "I_Graphics.h" 

//The derived interface elements tailored to the platform. 
#include "Windows_module.h" 
#include "D3D11_module.h" 
#include "EntityManager.h" 

// ** AUTHOR NOTE ** temporary until ini file reading is implemented 
#define FULL_SCREEN false 


/******************************************************************************* 
Purpose: 
This will be the central object that is responsible for containing and 
systematically initializing, updating per frame, and shutting down ALL the objects 
responsible for the various internal workings of the framework. This will also 
serve as the nexus for all external entities to retrieve data, interface with engine 
elements, as well as interfacing between eachother. 
********************************************************************************/ 

class System 
{ 
public: 

    /* All framework elements and interfaces contain an Initialization context to be 
    created outside, filled out, and passed into the Initalize function. This is to 
    maintain polymorphic similar function declarations, while still having variable 
    parameters */ 

    class InitializeContext 
    { 
    public: 
     HINSTANCE hinstance; 
    }; 

    System(); 
    ~System(); 

    bool Initialize(InitializeContext &); 
    void Run(); 
    void Shutdown(); 

public: 

    //pointer declarations of interface types for each framework element 
    std::shared_ptr<I_OS> m_os; 
    std::shared_ptr<I_Graphics> m_graphics; 
    std::shared_ptr<EntityManager> m_EntityManager; 
}; 


/* This will be the global pointer that all entities will use to access the 
public interface pointers to the entire framework. 

** AUTHOR NOTE ** : all entities should refer to the interfaces, and non platform 
specific elements to maintain crossplatform compatibility, (if it can be avoided)*/ 
extern std::shared_ptr<System> g_System; 

#endif 

EntityManager.h

/******************************************************************************* 
filename: EntityManager.h 

Author: 

Date: October 27, 2011 

********************************************************************************/ 

#ifndef ENTITY_MANAGER_H 
#define ENTITY_MANAGER_H 

#include <vector> 
#include <map> 
#include <fstream> 
#include <memory> 
#include "EntityBase.h" 
#include "EntityList.h" 

/******************************************************************************* 
Purpose: 
This wil be the object responsible for managing and updating all the various Entities 
currently rendered in a scene. It reads from a scene file and dynamically creates instances 
of the objects listed to be stored in a vector. these objects can be accessed individually 
by either index or unique string identifier, or you can obtain a vector that contains 
objects of the same class type. 
********************************************************************************/ 
class EntityManager 
{ 
public: 
    bool Initialize(); 
    bool Frame(); 
    void Shutdown(); 

private: 
    BaseFactory m_factory; 
    std::vector <std::shared_ptr<BaseEntity> > m_EntityList; 
    std::map<std::string, std::shared_ptr<BaseEntity> > m_EntityByNameList; 
    std::map<std::string, std::vector<std::shared_ptr<BaseEntity> > > m_EntityByClassList; 
}; 

#endif 

그래서 EntityManager의이 선언되지 않은 수의 원인이 될 수있는 이러한 문제 있나요? 출력에서 유일한 오류입니다. 더 이상 파일이 필요하다고 생각하고 포함 시키도록하겠습니다.

+3

원형 헤더 파일 포함의 전형적인 경우처럼 보입니다. 'EntityBase.h' 또는'EntityList.h'에는'system.h'가 포함되어 있습니까? BTW,'System.h'에'EntityManager.h'를 포함시킬 필요가 없습니다.'class EntityManager;의 forward 선언만으로 충분합니다. – Naveen

+0

실제로는 없습니다. 또한, 나는 앞으로 선언에 대해, 팁에 대한 감사를 알지 못했습니다 – FatalCatharsis

+1

당신은 재귀 적으로 검색에 갈 필요가 있습니다. 'EntityManager.h'에 포함 된 헤더 파일에'system.h'이 포함되어 있는지 확인해야합니다. – Naveen

답변

1

이것은 일반적으로 헤더 파일을 순환 포함하여 발생합니다. 귀하의 경우 EntityBase.h 또는 EntityList.h 중 하나에 System.h이 포함 된 것으로 보입니다. 이를 해결하는 가장 간단한 방법은 #include "EntityManager.h"System.h에서 제거하고 class EntityManager;system.h에 전달하는 것입니다. system.cpp#include "EntityManager.h"을 입력해야합니다.

+0

및 대답. 컴파일러가 알 수없는 식별자가 아닌 컴파일러에서 가져올 수있는 방법이 있었으면 좋겠지 만 컴파일러는 마술이 아닙니다. – FatalCatharsis

관련 문제