4
首先,我使用最新的mingw发行版在windows上使用代码块。我使用sfml库开始游戏,但不幸的是我遇到了这个问题。我需要为状态管理器使用std :: function,但它一直显示相同的错误:'std :: function'尚未声明。我做了#include<functional>
并使用链接器选项-std = C++ 0x,但仍然没有运气。唯一不编译的是这个头文件:Mingw'std :: function'尚未声明?
#ifndef STATEMANAGER_HPP_INCLUDED
#define STATEMANAGER_HPP_INCLUDED
#include <vector>
#include "State.hpp"
#include <functional>
#include <SFML/Graphics.hpp>
class StateManager {
public:
StateManager();
~StateManager();
void registerState(int id, std::function< State*() > createFunc);
void setState(int id);
void update();
void draw(sf::RenderTarget &target);
private:
std::vector< std::function< State*() > > mStates;
State *mCurrentState;
};
#endif // STATEMANAGER_HPP_INCLUDED
我不知道问题出在哪里。任何人都知道这里错了什么?
使用'--std = C++ 11'而不是过时的'C++ 0x' – Jarod42 2014-08-31 16:36:39
wil std :: tr1 :: function工作吗? –
2014-08-31 16:37:24
@PiotrS。然后它说tr1不是标准的成员 – user3452725 2014-08-31 16:40:43