1

私は自分のプログラムの最新ビルドをコンパイルしようとしましたが、恐ろしいことに VS から次のビルド エラー メッセージが表示されます。エラーメッセージをクリックして問題に移動すると、ctype.hヘッダーファイルに移動しますか??

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(22): error C2143: syntax error : missing ';' before 'string'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(22): error C2059: syntax error : 'string'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(22): error C2143: syntax error : missing ';' before '{'
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(22): error C2447: '{' : missing function header (old-style formal list?)

これで、ctype.h をいじっていないことがわかりました。

そして、前回のビルド以降に編集した唯一のファイルには、まだメイン コードへのエントリ ポイントさえありません。

以下にそれらを含めます。

ボウリングピン.cpp

#include <vector>
#include "BowlingPin.h"
#include "Entity.h"
#include <iostream>
#include <GL/glut.h>
#include "NormalCalculator.h"


vector<GLfloat> pinVerts;
vector<GLfloat> pinNorms;
vector<GLubyte> pinInd;
//declare a normal calculator
NormalCalculator normCalc;



BowlingPin::BowlingPin(NormalCalculator::GLpoint pos, NormalCalculator::GLpoint vel) : Entity(pos, vel)
{
    height = 40;
    width = 10;

    //create a normal calculator for use in a bit
    normCalc = NormalCalculator();


    createBoundingArray();//create the bounding array
    createPinVectors();//create the vertices of the object


} 

void BowlingPin::createBoundingArray()
{
    topSphere.centerPos.y = height - (width/2);
    topSphere.centerPos.x = position.x;//give the hitsphere the passed positions x and z values
    topSphere.centerPos.z = position.z;
    topSphere.radius = width/2;

    baseSphere.centerPos.y = width/2;
    baseSphere.centerPos.x = position.x;
    baseSphere.centerPos.z = position.z;
    baseSphere.radius = width/2;

    boundingArray.push_back(topSphere); //push them into the bounding array
    boundingArray.push_back(baseSphere);
}

int BowlingPin::whatIsBeingTouched(hitSphere otherSphere)
{
    if(boundingSphereIsTouching(topSphere, otherSphere))
    {
        return 0;
    }
    else if(boundingSphereIsTouching(baseSphere, otherSphere))
    {
        return 1;
    }
    else 
    {
        cout<<"/nERROR: The Bounding Sphere is touching absolutely nothing."<<endl;
        return 9999; //throw in a bit of psychotic behaviour in there in case i don't notice
    }
}

/////WHERE YOU LEFT OFF: you have created functions for detecting what part of the pin was hit.
//////Next is probably creating a function for detecting what 
/////direction/velocity the pin was hit from and determining which direction it should fly off in.
/////Then comes the bitch. Learn how to matrix rotate and have control enough to keep the hit spheres
/////in place on the pins in order to maintain programatic control.
/////Add states e.g. Static, Falling, Fallen for pins, so that we can calculate what to do.

void BowlingPin::createPinVectors()
{
    GLfloat tempVerts[51] = 
    {
        //Bottom
        position.x, position.y, position.z-(width/3),//close
        position.x-(width/3), position.y, position.z,//left
        position.x, position.y, position.z+(width/3),//far
        position.x+(width/3), position.y, position.z,//right
        //2nd floor
        position.x, position.y+(height/4), position.z-(width/2),//close
        position.x-(width/2), position.y+(height/4), position.z,//left
        position.x, position.y+(height/4), position.z+(width/2),//far
        position.x+(width/2), position.y+(height/4), position.z,//right
        //3rd floor
        position.x, position.y+(height/2), position.z-(width/3),//close
        position.x-(width/3), position.y+(height/2), position.z,//left
        position.x, position.y+(height/2), position.z+(width/3),//far
        position.x+(width/3), position.y+(height/2), position.z,//right
        //4th floor
        position.x, position.y+(height/2)+(height/4), position.z-(width/4),//close
        position.x-(width/4), position.y+(height/2)+(height/4), position.z,//left
        position.x, position.y+(height/2)+(height/4), position.z+(width/4),//far
        position.x+(width/4), position.y+(height/2)+(height/4), position.z,//right
        //apex
        position.x, position.y+height, position.z//middle

    };

    //copy these into the vertices vector

    for(int i = 0; i<51; i++)
    {
        pinInd.push_back(tempVerts[i]);
        printf("/nAdded %f to the pin's vertex array", tempVerts[i]);
    }

    ///get us some indices

    GLubyte tempIndices[90] = 
    {
        0,1,2,//Base
        0,2,3,
        0,5,4,//bottom face 1
        1,5,4,
        1,6,5,//bottom face 2
        1,2,6,
        3,7,6,//bottom face 3
        2,3,6,
        0,4,3,//bopttom face 4
        4,7,3,
        ///////next level
        4,5,8,//l2 1
        5,9,8,
        5,10,9,//l2 2
        5,6,10,
        6,11,10,//l2 3
        6,7,11,
        4,8,11,//l2 4
        4,11,7,
        ///////lvl 3
        8,13,12,//l3 1
        8,9,13,
        9,14,13,//l3 2
        9,12,13,
        10,15,14,//l3 3
        10,11,15,
        11,12,15,//l3 4
        11,8,12,
        /////////crown
        12,13,16,
        13,14,16,
        14,15,16,
        15,12,16

    };

    //load these into the pinInds array

    for(int i = 0; i<90; i++)
    {
        pinInd.push_back(tempIndices[i]);
        printf("\nAdded %i to the pins Index array",tempIndices[i]);
    }

}

そして、このクラスのヘッダーファイル

BowlingPin.h

#pragma once

#include "Entity.h"
#include "NormalCalculator.h"

class BowlingPin: public Entity
{

public: 
    BowlingPin(NormalCalculator::GLpoint pos, NormalCalculator::GLpoint vel);
    hitSphere topSphere; //the top hitSphere
    hitSphere baseSphere; //the bottom hitSphere
    int whatIsBeingTouched(hitSphere otherSphere); //when a collision is detected use this method to decide which of this pins spheres was hit. 0 = the top sphere and 1 = the bottom.
    NormalCalculator::GLpoint getNewVelocityFromImpactWith(NormalCalculator::GLpoint otherEntVel);


private:
    void createBoundingArray();//both creates (gives value to) the hitSpheres and adds them to the bounding array
    void rotatePin(GLfloat degrees); 
    int height;
    int width;

private:
    void createPinVectors();

}

これがどのようなエラーで、なぜ発生するのか、他の誰かが知っていますか?

4

1 に答える 1

7

BowlingPin クラスの最後にセミコロンがありません:-)

コンパイラ#includeが BowlingPin.h を展開すると、その後にコンパイルされた次のコード部分で「予想されるセミコロン」エラーが発生します。この場合、たまたま ctype.h に表示されます (これは経由で含まれている必要がありますiostream-- Entity.h は既に BowlingPin.h に含まれているため、iostream の前に含まれていても、Entity.h はエラーをトリガーしません。また、のために一度だけコンパイルされpragma onceます)。

于 2012-11-23T15:55:07.230 に答える