Search code examples
c++eclipsedictionarynamespaceseclipse-cdt

"Symbol 'map' could not be resolved" in namespace


Hello!

I am currently developing an game engine. Even though I only just started, I have already run into a problem.

I have this code:

#ifndef INSTANS_H_
#define INSTANS_H_
#include <map>
#include "Core/Version.h"
#include "Core/Window.h"
#include "Core/Component.h"
#include "Core/Game.h"

namespace Instans
{
    class Window;
    class Component;

    class Engine
    {
    public:
        Engine();
        ~Engine();

        void AddComponent(char* name, Component* component, int priority = 10);
        void RemoveComponent(char* name);

        void SetFramerateLimit(int limit);

        int GetFramerate();
        int GetFramerateLimit();

        void Run(char* title, int width, int height);
        void Load();

        void Update();
        void Render();

        void Release();
    protected:
    private:
        Window* _window;

        // Game, managers etc.
        std::map<int, char*, Component*> _components;
    };
};
#endif

Even though I have included , Eclipse gives me the following error:

Symbol 'map' could not be resolved Instans.h

What could be the cause?


Solution

  • The third parameter to map is a comparison function type, not a third contained data type. Chances are that's what's causing your problem.

    I can't quite tell what you're trying to do but if you're trying to map an int/string composite key to a Component you could use:

    std::map<std::pair<int, std::string>, Component*>