【发布时间】:2015-07-11 05:05:05
【问题描述】:
编译时出现错误:'Input' does not name a type on line 17
#ifndef GAME_H
#define GAME_H
#include "input.h"
// Can forward declare "class Input(GLFWwindow*);" here but it still
// gives the same error.
class Game
{
public:
Game(Input* input);
~Game();
void Input();
void Update();
void Render();
private:
Input* mpInput; //error here.
};
#endif // GAME_H
Input.h 看起来像这样。
#ifndef INPUT_H
#define INPUT_H
#include <GLFW/glfw3.h>
#include <vector>
class Input
{
public:
Input(GLFWwindow* window);
~Input();
bool GetKey(int keyCode);
bool GetKeyDown(int keyCode);
bool GetKeyUp(int keyCode);
void Update();
private:
GLFWwindow* mpWindow;
std::vector<bool> mCurrentKeys;
std::vector<bool> mDownKeys;
std::vector<bool> mUpKeys;
const int NUM_KEYCODES = 256;
};
#endif // INPUT_H
我不知道这里发生了什么。我昨天也遇到了类似的问题,一直想不通,所以我尝试保存项目,关闭 Code::Blocks,重新启动 Code::Blocks,然后重新打开项目。然后我编译了它,它没有明显的原因起作用。没有更改任何代码或任何东西。我也尝试在这里重新加载项目,但它仍然给出同样的错误。
【问题讨论】:
标签: c++ gcc compiler-errors codeblocks