Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Am i just not seeing it? (http://www.chiefdelphi.com/forums/showthread.php?t=53776)

Xenosthebest 09-02-2007 18:21

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!

ebowla 09-02-2007 18:36

Re: Am i just not seeing it?
 
did you try double clicking the error to see where it goes?

Dave Scheck 09-02-2007 18:38

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;
}

and got the following error
Code:

test.c:18: error: syntax error before "static"
Hope that helps.

Xenosthebest 09-02-2007 18:38

Re: Am i just not seeing it?
 
yes, i put a little arrow where it goes.

Jim E 09-02-2007 18:44

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.

:confused: :confused:

Xenosthebest 09-02-2007 18:44

Re: Am i just not seeing it?
 
yes i have checked for all missing braces and semicolons. still nothing.

lukevanoort 09-02-2007 18:46

Re: Am i just not seeing it?
 
Quote:

Originally Posted by Xenosthebest (Post 575119)
yes i have checked for all missing braces and semicolons. still nothing.

Can you attach the file?

gnirts 09-02-2007 20:28

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;
}

So do this:
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;
}

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


All times are GMT -5. The time now is 04:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi