c++ - * token 之前的预期初始化程序

标签 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

我不明白。它期望一个 init 是什么意思?提前致谢!

最佳答案

替换

#include "engine.hpp"

前向声明:

namespace spacecubes { class engine; }

关于c++ - * token 之前的预期初始化程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13900517/

相关文章:

c++ - C++ 中的转换问题(应为字符串)

c++ - boost io_service 不会重置

c++ - select() 行为的可写性?

c++ - 指向错误 : Linking Error in C++ 的指针

c++ - *(char**) 如何理解这个构造?

c++ - 使用 intel 编译器编译 DLL 时出错

c - 内存分配释放

nginx - Nginx-src/core/ngx_sha1.h :19:17: no such file or directory

plsql - PLS-00103 : Encountered the symbol “END” when expecting one of the following: . ; The symbol “;” was substituted for “END” to continue

c - 递增指针时未使用的表达式