Sign in to follow this  

A very annoying syntax Error and isn't an error.

Recommended Posts

C:\Users\Rosario\Desktop\Converge 8.0\Projects\OpenGL\main.cpp|278|error: expected primary-expression before ',' token|

This error comes after using this function:

      //  char buffer[256];
     //   sprintf(buffer,"Collision: ",true);
    //    drawText(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,buffer,1,1,1,1);

Now, I've looked through the function and everything seems in order. I might be missing something....Here's the function definition for your viewing pleasure:

bool EntityManager::checkCollisionBoundingBox(Entity* ent1, Entity* ent2)
    bool ret = false;
    Entities::iterator first;
    Entities::iterator second;

    Rectangle* rA = new Rectangle();
    Rectangle* rB = new Rectangle();

    first = mEntites.begin();
    while(first != mEntites.end())
        ent1 = (*first);
            second = mEntites.begin();
            while(second != mEntites.end())
                ent2 = (*second);
                if(ent2->isVisible() && ent1 != ent2)
                    // set the first rect.
                    rA->setLeft(ent1->getRectangle()->getLeft() + ent1->getXpos());
                    rA->setTop(ent1->getRectangle()->getTop() + ent1->getYpos());
                    rA->setRight(ent1->getRectangle()->getRight() + ent1->getRectangle()->getWidth() + ent1->getXpos() * ent1->getScale().getX());
                    rA->setBottom(ent1->getRectangle()->getBottom() + ent1->getRectangle()->getLength() + ent1->getYpos() * ent1->getScale().getY());

                    // set the second;
                    rB->setLeft(ent2->getRectangle()->getLeft() + ent2->getXpos());
                    rB->setTop(ent2->getRectangle()->getTop() + ent2->getYpos());
                    rB->setRight(ent2->getRectangle()->getRight() + ent2->getRectangle()->getWidth() + ent2->getXpos() * ent2->getScale().getX());
                    rB->setBottom(ent2->getRectangle()->getBottom() + ent2->getRectangle()->getLength() + ent2->getYpos() * ent2->getScale().getY());

                    if (rA->isInside( rB->getLeft(), rB->getTop() ) ||
                        rA->isInside( rB->getRight(), rB->getTop() ) ||
                        rA->isInside( rB->getLeft(), rB->getBottom() ) ||
                        rA->isInside( rB->getRight(), rB->getBottom() ))
                            ret = true;
    delete rA;
    delete rB;
    return ret;

Now sure if there's a syntax error in the function it self or not. I'm using code:blocks 12.11 with the  GNU GCC compiler. Please let me know what I did wrong, chances are.....I did something wrong.

Share this post

Link to post
Share on other sites

Is Ball a type? Ball sounds like something that might be a type, and thus the compiler won't want to treat it as an expression when you try to pass it as an argument to checkCollisionBoundingBox.


Or another possible scenario: is Ball a macro? If so, maybe the macro expands into something that isn't an expression, and the compiler is getting tripped up by it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this