View Full Version : Am i just not seeing it?
Xenosthebest
09-02-2007, 18:21
Every time i compile this code for our ramp control, itll tell me that i have a syntax error, when nothing is wrong.
Here it is:
Problem is here!---> static
void do_manual_override( void )
{
if (left_ramp_up == CLOSED)
{
left_motor_pwm = motor_up;
}
else if (left_ramp_down == CLOSED)
{
left_motor_pwm = motor_down;
}
else left_motor_pwm = motor_off;
if (right_ramp_up == CLOSED)
{
right_motor_pwm = motor_up;
}
else if (right_ramp_down == CLOSED)
{
right_motor_pwm = motor_down;
}
else right_motor_pwm = motor_off;
}
Any feedback is appreciated!
did you try double clicking the error to see where it goes?
Dave Scheck
09-02-2007, 18:38
That function compiles fine for me. My guess is that the error is actually in the line/statement above your function definition. Are you missing a semicolon, closing brace, or closing parenthesis there?
For example, I tried this code
/*Various declarations to get the function to compile */
.....
int x // <--- Missing semicolon
static void do_manual_override( void )
{
if (left_ramp_up == CLOSED)
{
left_motor_pwm = motor_up;
}
else if (left_ramp_down == CLOSED)
{
left_motor_pwm = motor_down;
}
else left_motor_pwm = motor_off;
if (right_ramp_up == CLOSED)
{
right_motor_pwm = motor_up;
}
else if (right_ramp_down == CLOSED)
{
right_motor_pwm = motor_down;
}
else right_motor_pwm = motor_off;
} and got the following errortest.c:18: error: syntax error before "static"Hope that helps.
Xenosthebest
09-02-2007, 18:38
yes, i put a little arrow where it goes.
I put you code into a default camera routine and it compiled and linked. I suspect the error you are seeing is just above the line where the syntax error is occurring. Look for a missing bracket or semi-colon.
:confused: :confused:
Xenosthebest
09-02-2007, 18:44
yes i have checked for all missing braces and semicolons. still nothing.
lukevanoort
09-02-2007, 18:46
yes i have checked for all missing braces and semicolons. still nothing.
Can you attach the file?
Check the file the was compiled just before it, or more likely the last file #include'd in the the file where the error appears. Look for missing }s. The compiler is weird that way, although possibly technically right, as the faulty syntax isn't until something unexpected happens, like when you try and start one function definition inside another one.
Another way to isolate invisible errors inside a file is to put known-good code before and after the line with the error, eg.
int someFunction(void) {
int i;
int j;
i = j /4; //this line is for some reason producing an error
return i;
}So do this:
int someFunction(void) {
int i;
int j;
printf("hello");
i = j /4; //this line is for some reason producing an error
printf("everyone");
return i;
}And see if the compiler still says its on the same line, or if it is now stopping on the upper or lower printf(). If so, then you know your error is on either side of the statement you were looking at, so check for the usual missing ; or }.
Good luck,
Robinson
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.