Repedative Syntax error : missing '=' and ')' and ';'

I wrote this section of code here today and everything went bad and i dont have a flipin clue why! More than likely i am simply missing a very minuet error probably from staring at the same lines of code for the past 7 hours.

these are the error messages i get ONLY in the section that i just wrote:

in_camera.cpp(453) : error C2143: syntax error : missing ';' before ')'

in_camera.cpp(454) : error C2143: syntax error : missing ';' before '{'

in_camera.cpp(454) : error C2059: syntax error : '='

in_camera.cpp(454) : error C2143: syntax error : missing ')' before ';'

in_camera.cpp(454) : error C2143: syntax error : missing ';' before ')'

in_camera.cpp(454) : error C2059: syntax error : ')'

in_camera.cpp(455) : error C2143: syntax error : missing ';' before '{'

in_camera.cpp(455) : error C2059: syntax error : '='

in_camera.cpp(455) : error C2143: syntax error : missing ';' before ')'

in_camera.cpp(457) : error C2181: illegal else without matching if

in_camera.cpp(457) : error C2059: syntax error : '='

except that there are like 80 more.

And here is the code i wrote.

//=====================================================================================================================
// Pirpose: Aim command, move cam over char's R shoulder
//========================================================


if( input->KeyState(&cam_aim) )
{ if( IsAim != true )
{ float AIMDP = cam_idealdist.GetFloat();
float AIMYP = cam_idealyaw.GetFloat();
float AIMPP = cam_idealpitch.GetFloat();
}

IsAim = true;
float CURD = cam_idealdist.GetFloat();
float CURY = cam_idealyaw.GetFloat();
float CURP = cam_idealpitch.GetFloat();

if( CURD != AIM_DIST )
{ if( (CURD - AIM_DIST) < 1.0 )
{ CURD -= (CURD - AIM_DIST);
}
else if( (CURD - AIM_DIST) < 9.0 )
{ CURD -= 0.5;
}
else if( (CURD - AIM_DIST) < 20.0 )
{ CURD -= 0.8;
}
else
{ CURD -= 1.0;
}
}

if( CURY != AIM_YAW )
{ if( (CURY > AIM_YAW )
{ if( (CURY - AIM_YAW) < 1.0)
{ CURY -= (CURY - AIM_YAW);
}
else if( (CURY - AIM_YAW) < 10.0)
{ CURY -= 0.7;
}
else
{ CURY -= 1.0;
}
}

if( CURY < AIM_YAW )
{ if( (CURY - AIM_YAW) > -1.0)
{ URY += (CURY - AIM_YAW);
}
else if( (CURY - AIM_YAW) > -10.0)
{ CURY += 0.7;
}
else
{ CURY += 1.0;
}
}
}
if( CURP != AIM_PITCH )
{ if( (CURP - AIM_PITCH) < 1.0 )
{ CURP -= (CURP - AIM_PITCH);
}
else if( (CURP - AIM_PITCH) < 10.0)
{ CURP -= 0.7;
}
else
{ CURP -= 1.0;
}
}
}


else
{ IsAim = false;
cam_idealdist.SetValue(AIMDP);
cam_idealyaw.SetValue(AIMYP);
cam_idealpitch.SetValue(AIMPP);
}

//================================================================================================================

Please, some one take a look and point out whats is wrong! I cant figure it out and would really appreciate if some one would help me out.

Thank



Answer this question

Repedative Syntax error : missing '=' and ')' and ';'

  • Jim McCarthy

    One 'trick' for resolving apparently confusing issues like this is to preprocess the file (use the /P or /E switches) this will show you what the compiler is actually seeing after the preprocessor has done its (black) magic.

  • MCTronix.com

    Okay, i wrote some new code and didnt get the errors, but when i rewrite the section of code that initially gave me the errors, i get the same thing. is there a limit to how many 'if' and 'else if' statements you can have within itself there has to be a reason for this!
  • karl_otto

    Please make sure you have a ; at the end of every class/structure/union/enum declaration. Missing a ; can lead to unrelated error reports (like these ones seem to be).

  • dazza70

    Unfortunatly i already caught that error and it still wasnt it. ive now rewritten the whole section into three seperate function and still the exact same thing.

    This is what it looks like now and the errors start with " missing '=' " at the very first if statement.

    ===========================================================================

    float aimDistAdj( float curd )
    {
    if(CURD != AIM_DIST )
    { if( (CURD - AIM_DIST) < 1.0 )
    { CURD -= (CURD - AIM_DIST);
    }
    else if( (CURD - AIM_DIST) < 9.0 )
    { CURD -= 0.5;
    }
    else if( (CURD - AIM_DIST) < 20.0 )
    { CURD -= 0.8;
    }
    else
    { CURD -= 1.0;
    }
    }
    return curd;
    }

    float aimYawAdj( float cury )
    {
    if( CURY != AIM_YAW )
    { if( CURY > AIM_YAW)
    { if( (CURY - AIM_YAW) < 1.0 )
    { CURY -= (CURY - AIM_YAW);
    }
    else if( (CURY - AIM_YAW) < 10.0)
    { CURY -= 0.7;
    }
    else
    { CURY -= 1.0;
    }
    }

    if( CURY < AIM_YAW )
    { if( (CURY - AIM_YAW) < -1.0)
    { CURY += (CURY - AIM_YAW);
    }
    else if( (CURY - AIM_YAW) < -10.0)
    { CURY += 0.7;
    }
    else
    { CURY += 1.0;
    }
    }
    }
    return cury;
    }

    float aimPitchAdj( float curp )
    {
    if( CURP != AIM_PITCH )
    { if( (CURP - AIM_PITCH) < 1.0 )
    { CURP -= (CURP - AIM_PITCH);
    }
    else if( (CURP - AIM_PITCH) < 10.0)
    { CURP -= 0.7;
    }
    else
    { CURP -= 1.0;
    }
    }
    return curp;
    }

    ==========================================================================

    This is driving me batty!


  • Santig

    sounds great, although one problem. Where do i put in those switches Bear with me, im a self taught programmer.


  • Rattlerr

    Hi,
    float aimDistAdj( float curd )
    {
    if(CURD != AIM_DIST )
    // ....

    In line 3, is CURD supposed to be the curd from the function arguments(line1 Because if that's the case then you have to write it the same way you have in the arguments. In C/C++ variables/constants/etc.. are case sensitive.



  • Doug DeBug

    I'm sure that the compiler handles pretty nice the if's/else if's in the code you posted in your first posts and many more encapsulated if's, although I can't say what the limit is, or if there is one.
    If you post the code you're using maybe I (or someone else) will be able to help.


  • robertz2

    Well, this code is OK (compiles successfully).

    float AIM_DIST = 0.0f;
    float AIM_YAW = 0.0f;
    float AIM_PITCH = 0.0f;

    float aimDistAdj( float curd )
    {
    if(curd != AIM_DIST )
    { if( (curd - AIM_DIST) < 1.0 )
    { curd -= (curd - AIM_DIST);
    }
    else if( (curd - AIM_DIST) < 9.0 )
    { curd -= 0.5;
    }
    else if( (curd - AIM_DIST) < 20.0 )
    { curd -= 0.8;
    }
    else
    { curd -= 1.0;
    }
    }
    return curd;
    }

    float aimYawAdj( float CURY )
    {
    if( CURY != AIM_YAW )
    { if( CURY > AIM_YAW)
    { if( (CURY - AIM_YAW) < 1.0 )
    { CURY -= (CURY - AIM_YAW);
    }
    else if( (CURY - AIM_YAW) < 10.0)
    { CURY -= 0.7;
    }
    else
    { CURY -= 1.0;
    }
    }

    if( CURY < AIM_YAW )
    { if( (CURY - AIM_YAW) < -1.0)
    { CURY += (CURY - AIM_YAW);
    }
    else if( (CURY - AIM_YAW) < -10.0)
    { CURY += 0.7;
    }
    else
    { CURY += 1.0;
    }
    }
    }
    return CURY;
    }

    float aimPitchAdj( float CURP )
    {
    if( CURP != AIM_PITCH )
    { if( (CURP - AIM_PITCH) < 1.0 )
    { CURP -= (CURP - AIM_PITCH);
    }
    else if( (CURP - AIM_PITCH) < 10.0)
    { CURP -= 0.7;
    }
    else
    { CURP -= 1.0;
    }
    }
    return CURP;
    }

    Do you get any error for it



  • DaveJ4

    STILL NOTHING!!! This blows. i've fixed every error i can find and the ones youve pointed out and still nothing. it seems like i used the wrong font or somethign bacuase it never picks up any error other than missing constants. its like the compiler dfoesnt even recognize the constants that i used in just that section of code, could it be something with the font or something else similar because there is no reason for it to get these errors. it wont even pick up any error that i purposly added in,. jusrt the syntax errors. ill write some new code and see if it does the same thing.
  • taboryee

    I totally understand and agree Jonathan. Although im from a bit younger generation, i know the importance of knowing how and why a program or operating systems does what it does behind the scnenes. if i had known about the compiler command line i would have been using that already, my problem is that i have only just recently made the jump from C++ to Visual C++. so im still getting used to VC++ .NET '03.

    Thanks for the help, i really appreciate it!

    Nathan


  • Przemo2

    Hi,
    look carefully at the line in the middle of these:

    if( CURY != AIM_YAW )
    { if( (CURY > AIM_YAW )
    { if( (CURY - AIM_YAW) < 1.0)


    there's a ( that shouldn't be there ;)
    Next time to make things a bit easier, you should indicate which line/lines are the ones that have the error ;)


  • 5letters

    I'm an old guy so I tend to compile from the command-line most of the time - and I still feel that this is a skill that is useful - especially for learning how the compiler works. In this case I would use

    cl /P <other-options> myfile.cpp

    This will cause the compiler to generate myfile.i

    From the IDE I would go to Project -> Properties -> C/C++ -> Preprocessor

    and then change "Generate Preprocessed File" to one of the "Yes" options.



  • Uzzy

    AWSOME! it works! well, it compiled, now i just have to deal with the conflicting bugs n stuff. Thank a bunch! i take it it was the AIM_*** variables, since i (for some reasone) used #define to create them. man, i cant thank you enough.
  • Repedative Syntax error : missing '=' and ')' and ';'