我試圖移植在linux/g ++中開發的程序/遊戲,以便它在Windows 7 VS 2008 C++上運行。該程序使用諸如OpenGL,SDL和Boost等庫。VS 2008 C++錯誤C2059和C2238
我已經解決了很多錯誤,但我有點卡在這一個。
我得到錯誤代碼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的異步和序列化模塊。我知道Boost有時會發出奇怪的警告,但我不確定Boost是否必須對此錯誤執行任何操作。
如果有人有任何想法,爲什麼這是或如果你需要更多的代碼張貼,請讓我知道。
將變量名更改爲* Plane(即 - nearPlane)修正了此錯誤。謝謝! – 2011-05-22 06:53:15