我正在尝试移植用linux / g ++开发的程序/游戏,以便它在Windows 7 VS 2008 C ++上运行。该程序使用OpenGL,SDL和Boost等库。
我已经解决了很多错误,但我有点困惑于此。
我收到错误代码C2059和C2238。实际的错误消息是:
------ Build started: Project: Asteroid Blaster, Configuration: Release Win32 ------
Compiling...
WeaponDisplay.cpp
Weapon.cpp
ViewFrustum.cpp
Vector3D.cpp
UDP_Server.cpp
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2238: unexpected token(s) preceding ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2238: unexpected token(s) preceding ';'
UDP_Client.cpp
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(40) : error C2238: unexpected token(s) preceding ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2059: syntax error : ';'
d:\College\AsteroidBlaster\Utility/ViewFrustum.h(41) : error C2238: unexpected token(s) preceding ';'
TractorBeamShot.cpp
ViewFrustum.h文件如下:
/**
* viewFrustum: It's got useful functions to cull items that aren't in your view frustum
*
* 2-7-11
* CPE ---
*/
#ifndef __VIEW_FRUSTUM_H__
#define __VIEW_FRUSTUM_H__
#include "Items/Object3D.h"
#include "Utility/Plane.h"
#include "Utility/Matrix4.h"
#include <vector>
#include <set>
class ViewFrustum {
public:
ViewFrustum();
virtual ~ViewFrustum();
/* Takes in a list of all the Object 3D's around, and culls them down to only the ones
* that are inside the view frustum.
*/
virtual std::list<Drawable*>* cullToViewFrustum(std::vector<Drawable*>* all, bool skipParticles);
virtual std::list<Object3D*>* cullToViewFrustum(std::vector<Object3D*>* all);
/* Prints out details about all of the planes of the view frustum.
*/
virtual void print();
private:
Matrix4 projMatrix;
Matrix4 modelViewMatrix;
Plane* top;
Plane* bottom;
Plane* left;
Plane* right;
Plane* near;
Plane* far;
/**
* A modified version of chedDrawableOutside, used by the AI. This stops the
* AI from targeting Drawable objects which are slightly outside the field
* of view, which still need to be drawn.
*/
bool checkTargetableOutside(Drawable* obj);
/* Returns true if the Drawable object is completely outside of the
* view frustum planes.
* Returns false if it's even part-way inside.
*/
virtual bool checkDrawableOutside(Drawable* obj);
};
#endif
违规行(40-41)是:
Plane* near;
Plane* far;
这有点令人困惑,因为ViewFrustum obj已经编译了,但是当它到达UDP_Server.cpp和UDP_Client.cpp时,它会抛出一个错误。我不确定它是否重要,但UDP类使用Boost的aiso和序列化模块。我知道Boost有时会发出奇怪的警告,但我不确定Boost是否必须对此错误做任何事情。
如果有人知道为什么会这样或者您需要发布更多代码,请告诉我们。
答案 0 :(得分:4)
您可能在该标题之前包含了一个Windows标题,并且near
和far
已定义在那里。那些是16位时代的(遗留)事物。
有关解决方法,请参阅此相关问题Is there a clean way to prevent windows.h from creating a near & far macro?。