Go to Post If it's not on fire, it's a software problem. - Matt Leese [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2008, 18:27
greatman05 greatman05 is offline
Registered User
AKA: Chavez Clemons Jr.
FRC #2224 (Phoenix Phenoms)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Detroit, MI
Posts: 32
greatman05 is an unknown quantity at this point
Send a message via AIM to greatman05 Send a message via MSN to greatman05 Send a message via Yahoo to greatman05
This code will NOT compile

Hello. We're having a problem...The compiler won't compile this, and we don't know why...Is there anything wrong? It seems syntactically correct...
Attached Files
File Type: c user_routines.c (15.0 KB, 70 views)
  #2   Spotlight this post!  
Unread 15-02-2008, 18:43
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: This code will NOT compile

Code:
int cube (p1_y);
{
return p1_y * p1_y * p1_y
} 

int cube2 (p2_y);
{
return p2_y * p2_y * p2_y
}

int square (p1_y);
{
return p1_y * p1_y
}

int square2 (p2_y);
{
return p2_y * p2_y
}
You are declaring these functions inside the default_routine function. They should be outside any functions.
  #3   Spotlight this post!  
Unread 15-02-2008, 19:03
greatman05 greatman05 is offline
Registered User
AKA: Chavez Clemons Jr.
FRC #2224 (Phoenix Phenoms)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Detroit, MI
Posts: 32
greatman05 is an unknown quantity at this point
Send a message via AIM to greatman05 Send a message via MSN to greatman05 Send a message via Yahoo to greatman05
Re: This code will NOT compile

We didi put it outside any functions...at the top of the "user routines" file, and it still wouldn't be compile...Where should the declarations of functions and any user code we need go?

Last edited by greatman05 : 15-02-2008 at 19:05.
  #4   Spotlight this post!  
Unread 15-02-2008, 19:49
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: This code will NOT compile

I noticed a few more errors in your functions.

Code:
int square2 (p2_y);
{
return p2_y * p2_y
}
If you want it to take a variable you pass, you need to declare the type of variable. Also, you shouldn't have a semicolon on the end of the declaration but should on the return statement. p2_y is a global variable, so it's not wise to also use it as a local variable (I don't think it will cause a compile error, but it is confusing to read).

If you want separate functions for each joystick axis, you could write it like:
Code:
int square2 ()
{
return (p2_y * p2_y);
}
For a generic function, you could write

Code:
int square2 (int variable_to_square)
{
return (variable_to_square * variable_to_square);
}



Note: It's much easier to help if you tell us what the error message is and what code is causing it.
  #5   Spotlight this post!  
Unread 15-02-2008, 19:59
greatman05 greatman05 is offline
Registered User
AKA: Chavez Clemons Jr.
FRC #2224 (Phoenix Phenoms)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Detroit, MI
Posts: 32
greatman05 is an unknown quantity at this point
Send a message via AIM to greatman05 Send a message via MSN to greatman05 Send a message via Yahoo to greatman05
Re: This code will NOT compile

OK...Thanks! It basically was a syntax error, and everytime we got something to work, it had a syntax error with the "{" and/or the "}"...the file was the user_routines.c file, where I thought you were supposed to put user code...
  #6   Spotlight this post!  
Unread 15-02-2008, 20:27
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: This code will NOT compile

Code:
int cube1 (unsigned char p1_y)
{
return((int)p1_y * (int)p1_y * (int)p1_y);
}
and you'll need to use casts to up the unsigned char to ints. Also, you can't use p1_y as a passed argument - its defined in ifi_aliases.h:

Code:
ifi_aliases.h:30: #define p1_y        rxdata.oi_analog01

and unless you are absolutely certain of the precedence rules for applying operations - use parentheses to eliminate any questions:
Code:
 
pwm01 = cube()  - (3 * square() ) + (5 * p1_y);  /*x^3-3x^2+5x* A cubic function to regulate the sensitivity of the robot's drive*/
  pwm02 = cube2() - (3 * square2()) + (5 * p2_y); /*same thing, son*/
Attached Files
File Type: c user_routines.c (15.2 KB, 51 views)
File Type: c user_routines_diff.c (3.8 KB, 27 views)

Last edited by dcbrown : 15-02-2008 at 20:52.
  #7   Spotlight this post!  
Unread 16-02-2008, 16:07
purduephotog purduephotog is offline
Active Defense Design Engineer
AKA: Jason
FRC #3015
Team Role: Leadership
 
Join Date: Jan 2007
Rookie Year: 2004
Location: Rochester, NY
Posts: 162
purduephotog is a jewel in the roughpurduephotog is a jewel in the roughpurduephotog is a jewel in the roughpurduephotog is a jewel in the rough
Send a message via AIM to purduephotog
Re: This code will NOT compile

Quote:
Originally Posted by greatman05 View Post
Hello. We're having a problem...The compiler won't compile this, and we don't know why...Is there anything wrong? It seems syntactically correct...
Actually you're missing semi colons everywhere.
__________________
http://purduephotog.deviantart.com
Portrait Photography: "I used to say Immortalized in Silver, but now I say Captured and Squeezed by Electrons".
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Default code will not compile bronxbomber92 Programming 7 18-01-2008 18:44
Does anyone else think this game will not be as good as I imagine it might be? NeedMoreEngines FRC Game Design 76 15-01-2006 21:15
heres the code. y this not working omega Programming 16 31-03-2004 15:18
What is wrong with this code???? It won't Compile and I don't know why? Please Help CrashZero Programming 23 26-03-2004 09:44
My other computer will not work with this forum! David Kelso CD Forum Support 4 04-06-2001 21:52


All times are GMT -5. The time now is 00:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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