开发者

VS 2008 C++ error C2059 and C2238

I'm trying to port a program/game that was developed in linux/g++ so that it runs on windows 7 VS 2008 C++. The program uses libraries such as OpenGL, SDL, and Boost.

I've solved a lot of errors but I'm kind of stuck on this one.

I get error code C2059 and C2238. The actual error messages are:

------ 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

The ViewFrustum.h file is as follows:

  /**
   * 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 

The offending lines (40-41) are:

  Plane* near;
  Plane* far;

It's kind of confusing because the ViewFrustum obj got compiled already but when it gets to UDP_Server.cpp and UDP_Client.cpp, it throws an error. I'm not sure if it matters but the UDP classes use Boost's aiso and serialization modules. I know Boost sometimes gives out weird warnings but I'm not sure if Boost has to do anything with this error.

If anyone has any idea why this is or if you need more code posted, please let me know.


Chances are you're including a windows header before that one, and near and far are defined somehwere in there. Those are (legacy) things from the 16bit era.

See this related question Is there a clean way to prevent windows.h from creating a near & far macro? for workarounds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜