声明没有声明任何[-fpermissive]错误

xxl*_*ali 1 c++

我得到"decleration没有声明任何[-fpermissive]错误"; 这是我的代码;

#ifndef CAMERA_H
#define CAMERA_H
#include "Vector.h"
#include <string>

using namespace std;

class Camera
{
    private:
        int id;
        float position[3];
        Vector gaze;
        Vector up;
        float left;
        float right;
        float bottom;
        float top;
        float near;
        float far;
        int type;

    public:
        Camera(int i,string c, string g, string u, string f, string t);
        int getID() {return id; }
        float* getPosition() { return position; }
        Vector getGaze() { return gaze; }
        Vector getUp() { return up; }
        float getLeft() {return left;}
        float getRight() {return right;}
        float getBottom() {return bottom;}
        float getTop() {return top;}
        float getNear() {return near;}
        float getFar() {return far;}
        int getType() {return type;}
};

#endif // CAMERA_H
Run Code Online (Sandbox Code Playgroud)

错误从"浮动附近"开始 接下来的3行.

这个错误的原因是什么,我该如何修复它.

Die*_*ühl 7

替换nearfar其他东西,至少对于测试,例如near_far_:我怀疑你正在编译一些有趣的标题,它定义near并且far什么都不是.在遥远的过去,这两个是在一些平台上用来处理不同大小的指针的关键词.

如果要验证理论,请使用-E选项处理源文件(您可能需要从编译行中删除其他选项,例如-c):使用此选项,编译器将生成预处理的输出.如果你捕获它并在那里查看你的类,我很确定它不会包含成员名称.

  • 问题是,字符串被定义为使用预处理器,即"#defined near"之类的东西.在过去,一些指针被声明为`int near*pointer;`但是较新的编译器不理解这种表示法.使用宏,声明看起来像`int*pointer;`到编译器,你的声明变成`float;`,而不是声明任何东西.然而,潜在的问题更加可怕:你的老师至少10年没有更新他的标题,更可能是20年([这里](http://en.wikipedia.org/wiki/Far_pointer)更多一点信息). (3认同)