|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Am i just not seeing it?
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! |
|
#2
|
||||
|
||||
|
Re: Am i just not seeing it?
did you try double clicking the error to see where it goes?
|
|
#3
|
|||
|
|||
|
Re: Am i just not seeing it?
yes, i put a little arrow where it goes.
|
|
#4
|
||||
|
||||
|
Re: Am i just not seeing it?
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 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;
}
Code:
test.c:18: error: syntax error before "static" |
|
#5
|
|||
|
|||
|
Re: Am i just not seeing it?
yes i have checked for all missing braces and semicolons. still nothing.
|
|
#6
|
||||
|
||||
|
Re: Am i just not seeing it?
Can you attach the file?
|
|
#7
|
|||
|
|||
|
Re: Am i just not seeing it?
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. Code:
int someFunction(void) {
int i;
int j;
i = j /4; //this line is for some reason producing an error
return i;
}
Code:
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;
}
Good luck, Robinson |
|
#8
|
|||
|
|||
|
Re: Am i just not seeing it?
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.
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| pic: Just was not enough room | Rich Wong | Extra Discussion | 6 | 15-04-2005 18:58 |
| It's not just about the competition! | Franchesca | General Forum | 8 | 28-07-2004 13:31 |
| digital inputs not valid just after initialization? | WizardOfAz | Programming | 2 | 26-01-2004 13:21 |
| NO, I'm not just reviving a dead forum | Hubicki | Rules/Strategy | 6 | 14-07-2002 17:44 |