MinGW and "declaration declare nothing"
I am working on converting my Linux project to compile on Windows using MinGW. It compiles and works fine on Linux, but when I try to compile it with MinGW, it gives me the following error:
camera.h:11: error: declaration does not declare anything
camera.h:12: error: declaration does not declare anything
I'm a little puzzled as to why this is happening because
- I am using the same g ++ (4.4) version for Linux and Windows (via MinGW).
- The contents of the .h camera are absurdly simple.
Here is the code. It chokes on lines 11 and 12 where float near;
and are defined 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
Thanks for your help.
EDIT: Thanks to both Dirk and mingos, that was exactly the problem!
a source to share
In <windef.h>
you will find the following lines:
#define NEAR
#define near
Simple answer: you can't have #undef
them because they are part of the Windows headers (_WINDEF_H will still be defined even if you do #undef
these definitions, so it won't be re-enabled if you try #include <windef.h>
again, let alone if you #undef _WINDEF_H
before use #include <windef.h>
after defining your class, you will end up with duplicate definitions for things like RECT, LONG, PROC, etc.), so the only other solution is to change the variable names.
a source to share