gpt4 book ai didi

g++ - MinGW 和 "declaration does not declare anything"

转载 作者:行者123 更新时间:2023-12-01 09:39:17 30 4
gpt4 key购买 nike

我正在使用 MinGW 将我的 Linux 项目转换为在 Windows 上编译。它在 Linux 上编译和运行都很好,但是当我尝试用 MinGW 编译它时,它会出现以下错误消息:

camera.h:11: error: declaration does not declare anything
camera.h:12: error: declaration does not declare anything

我有点困惑为什么会这样,因为

  1. 我在 Linux 和 Windows(通过 MinGW)上使用相同版本的 g++ (4.4)。
  2. camera.h 的内容非常简单。

这是代码。它在第 11 行和第 12 行阻塞,其中定义了 float near;float far;

#include "Vector.h"

#ifndef _CAMERA_H_
#define _CAMERA_H_

class Camera{
public:
Vector eye;
Vector lookAt;
float fov;
float near;
float far;
};

#endif

感谢您的帮助。

编辑:感谢 Dirk 和 mingos,这正是问题所在!

最佳答案

编辑如果你碰巧包含windef.h(直接或间接),你会发现

#define FAR
#define far
#define NEAR
#define near

那里。我认为,这是罪魁祸首。

试试

#undef near
#undef far

在你的类定义之前。

关于g++ - MinGW 和 "declaration does not declare anything",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2754937/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com