*令牌之前的预期初始化程序

时间:2012-12-16 10:47:08

标签: c++ pointers compiler-errors

所以我有这个头文件:

#pragma once

#include "engine.hpp"

namespace spacecubes
{
  extern engine* _engine;
}

和包含的engine.hpp:

#pragma once

#include <iostream>

#include "glinclude.hpp"
#include "debug.hpp"
#include "convert.hpp"
#include "renderer.hpp"
#include "global.hpp"

namespace spacecubes {
    void display();

    class engine {
        renderer renderengine;

    public:
        void start(int argc, char* argv[]);
        void stop(int status = 0);
        void poll();

        renderer getRenderEngine() {return renderengine;}
    };
}

后来编译器报告的是:

g++  -c -o bin/obj/engine.o src/engine.cpp
In file included from src/engine.hpp:9,
                 from src/engine.cpp:1:
src/global.hpp:7: error: expected initializer before '*' token
src/engine.cpp: In function 'void spacecubes::display()':
src/engine.cpp:5: error: '_engine' was not declared in this scope

我不明白。这对初学者来说意味着什么?提前谢谢!

1 个答案:

答案 0 :(得分:1)

替换

#include "engine.hpp"

带有前瞻声明:

namespace spacecubes { class engine; }