Go to Post The reason I care about it is that I don't want minorities (whether that's females or other racial minorities) to see the STEM world as only inclusive of majorities or men. - Monochron [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 20-01-2007, 13:12
fallen751 fallen751 is offline
Registered User
FRC #2052
 
Join Date: Jan 2007
Location: Minnesota
Posts: 17
fallen751 is an unknown quantity at this point
hey, stupid question but...

I was wondering if anyone could give me any help. I keep coming up with an error when I try to use this function definition. I haven't declared the function in anywhere else other then this, and it is ahead of any calls to the function so I let it be its own prototype.

Code:
int intMax(int x, int y)
{                                //here is where I get the syntax error
	int max = x;
	if(y > max)
	{
   		max = y;
	}
   return max;
}
would I have to use it as an inline function? any help would be great!
  #2   Spotlight this post!  
Unread 20-01-2007, 13:15
Adam Richards's Avatar
Adam Richards Adam Richards is offline
I'm baaaaaaack.
FRC #1902 (Exploding Bacon)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Orlando, FL
Posts: 1,062
Adam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond repute
Send a message via AIM to Adam Richards
Re: hey, stupid question but...

Hmm, I don't do C much, but have you tried declaring a function prototype at the start of the code?

Code:
// Include files

//Prototypes
int intMax(int x, int y);

//main,intMax,etc. below
Also, telling us what error you're receiving might be helpful. Thanks!
  #3   Spotlight this post!  
Unread 20-01-2007, 13:21
fallen751 fallen751 is offline
Registered User
FRC #2052
 
Join Date: Jan 2007
Location: Minnesota
Posts: 17
fallen751 is an unknown quantity at this point
Re: hey, stupid question but...

thanks for the quick response! I just tried prototyping it, but no luck. The exact error i'm getting looks like this

Code:
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\main.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_routines_fast.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_SerialDrv.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\ifi_startup.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\ifi_utilities.o".
Clean: Done.
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "main.c" -fo="main.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_routines_fast.c" -fo="user_routines_fast.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_SerialDrv.c" -fo="user_SerialDrv.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "ifi_startup.c" -fo="ifi_startup.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "ifi_utilities.c" -fo="ifi_utilities.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_routines.c" -fo="user_routines.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_routines.c:228:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Sat Jan 20 12:21:21 2007
  #4   Spotlight this post!  
Unread 20-01-2007, 13:23
Adam Richards's Avatar
Adam Richards Adam Richards is offline
I'm baaaaaaack.
FRC #1902 (Exploding Bacon)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Orlando, FL
Posts: 1,062
Adam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond repute
Send a message via AIM to Adam Richards
Re: hey, stupid question but...

Quote:
Originally Posted by fallen751 View Post
thanks for the quick response! I just tried prototyping it, but no luck. The exact error i'm getting looks like this

Code:
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\main.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_routines_fast.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_SerialDrv.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\ifi_startup.o".
Clean: Deleted file "C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\ifi_utilities.o".
Clean: Done.
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "main.c" -fo="main.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_routines_fast.c" -fo="user_routines_fast.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_SerialDrv.c" -fo="user_SerialDrv.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "ifi_startup.c" -fo="ifi_startup.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "ifi_utilities.c" -fo="ifi_utilities.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8722 "user_routines.c" -fo="user_routines.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_LARGE_CODE -D_DONT_USE_TMR0 -mL -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
C:\Documents and Settings\Mounds View Schools\My Documents\FrcCode_2007_8722\user_routines.c:228:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Sat Jan 20 12:21:21 2007
Your compiler is telling you that there's an error on line 228 of user_routines.c. Could you post that function and boldface/highlight in some way line 228?

Have you declared any globals x or y already?

Last edited by Adam Richards : 20-01-2007 at 13:25.
  #5   Spotlight this post!  
Unread 20-01-2007, 13:26
fallen751 fallen751 is offline
Registered User
FRC #2052
 
Join Date: Jan 2007
Location: Minnesota
Posts: 17
fallen751 is an unknown quantity at this point
Re: hey, stupid question but...

I don't want to post the entire code (our homebrew mecanum drive code) but at the top of the post where I comment by the bracket is line 228. thanks for your help
  #6   Spotlight this post!  
Unread 20-01-2007, 13:30
Adam Richards's Avatar
Adam Richards Adam Richards is offline
I'm baaaaaaack.
FRC #1902 (Exploding Bacon)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Orlando, FL
Posts: 1,062
Adam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond reputeAdam Richards has a reputation beyond repute
Send a message via AIM to Adam Richards
Re: hey, stupid question but...

Since I can't see the whole code, and I won't know what functions might already be predefined, have you tried renaming the function to something other than intMax? Try just qwerty or something miscellaneous for now to see if the function might already have been reserved for something.
  #7   Spotlight this post!  
Unread 20-01-2007, 13:33
maniac_2040's Avatar
maniac_2040 maniac_2040 is offline
Registered User
AKA: Matt
FRC #3302 (Turbo Trojans)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Clawson, Michigan
Posts: 34
maniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these partsmaniac_2040 is infamous around these parts
Send a message via MSN to maniac_2040
Re: hey, stupid question but...

Check around in your code. It is likely that the syntax error is actually entirely unrelated to that section of the code. Looks like you might have a missing brace or semicolon somewhere.
  #8   Spotlight this post!  
Unread 20-01-2007, 15:25
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: hey, stupid question but...

Thank you for calling the Department of Redundancy Agency.


Have you checked for a missing semicolon or closing brace?


__________________
http://www.mikesorrenti.com/
  #9   Spotlight this post!  
Unread 20-01-2007, 15:31
chrisinmd's Avatar
chrisinmd chrisinmd is offline
Registered User
AKA: Chris Pickett
FRC #0888 (Robotiators)
Team Role: College Student
 
Join Date: Jan 2006
Location: Mt. Airy, MD
Posts: 83
chrisinmd is a jewel in the roughchrisinmd is a jewel in the roughchrisinmd is a jewel in the rough
Send a message via AIM to chrisinmd
Re: hey, stupid question but...

This may or may not be way off, but I remember reading somewhere that the C18 compiler has trouble with filenames longer than 64 characters. It wouldn't compile some code that I had in the My Documents folder once, so I put all the code in a folder in the root c: directory. Worked fine after that.
Just something I remember, may or may not help you!
Hope you get it figured out.
Best of luck,
-Chris
__________________
Virginia Tech 2010!

Chesapeake Regional
Pittsburgh Regional
  #10   Spotlight this post!  
Unread 20-01-2007, 15:32
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,277
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: hey, stupid question but...

Quote:
Originally Posted by chrisinmd View Post
This may or may not be way off, but I remember reading somewhere that the C18 compiler has trouble with filenames longer than 64 characters. It wouldn't compile some code that I had in the My Documents folder once, so I put all the code in a folder in the root c: directory. Worked fine after that.
Just something I remember, may or may not help you!
Hope you get it figured out.
Best of luck,
-Chris
You are right about there being a size limit but that would have given a different error.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
  #11   Spotlight this post!  
Unread 20-01-2007, 15:57
brainonska's Avatar
brainonska brainonska is offline
Registered User
AKA: Magical Steve
FRC #1155 (Sciborgs)
Team Role: Programmer
 
Join Date: Apr 2006
Rookie Year: 2006
Location: New York City
Posts: 19
brainonska is an unknown quantity at this point
Send a message via AIM to brainonska
Re: hey, stupid question but...

i could be wrong...

but you declared the integer variable "max" in the function.

try putting "int max;" in your first line of code along with all your other variable declarations and then in the function... "max = ..."
__________________
Real programmers don't comment their code:
it was hard to write... it should be hard to understand
  #12   Spotlight this post!  
Unread 20-01-2007, 17:09
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: hey, stupid question but...

Quote:
Originally Posted by brainonska View Post
i could be wrong...

but you declared the integer variable "max" in the function.

try putting "int max;" in your first line of code along with all your other variable declarations and then in the function... "max = ..."
All that would do is make it global, and the error would be different for that. I'm with Mike and the gang, I say it's an error in a previous line, or it doesn't like using int in the function name.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #13   Spotlight this post!  
Unread 20-01-2007, 13:32
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: hey, stupid question but...

Look closely at the lines preceding the one identified as causing the error. I'm guessing you have a missing semicolon or close brace somewhere before your intMax function definition.
  #14   Spotlight this post!  
Unread 20-01-2007, 17:55
tckma's Avatar
tckma tckma is offline
Registered User
AKA: Tom C.
FRC #2199 (Robo-Lions)
Team Role: Mentor
 
Join Date: Nov 2004
Rookie Year: 2002
Location: Westminster, MD
Posts: 90
tckma has a spectacular aura abouttckma has a spectacular aura abouttckma has a spectacular aura about
Send a message via ICQ to tckma Send a message via AIM to tckma Send a message via Yahoo to tckma
Re: hey, stupid question but...

Are you just trying to build the code or is this error occurring when you download to the RC? If the former, I'd suggest heeding prior suggestions to check for a missing semicolon and/or brace. If the latter, I would check if you may be running out of program memory on the processor. This isn't as much of a problem with 2006 and 2007 RCs as it is with 2005 and earlier RCs, since they increased the code space for 2006. I doubt this is the problem, but my team has run into memory issues in the past.
__________________
Tom C.
Software and Controls Mentor
Team 2849
Prior team associations: 1418 ('08-'09), 1100 ('05-'08), 811 ('02, '04-'05), 246 ('03)

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
Stupid Variable question.... BillyJ Programming 3 20-02-2006 19:49
Stupid question but... Adam Y. Math and Science 6 16-02-2004 19:29
Really stupid question psychoCHIPMUNKK Kit & Additional Hardware 3 15-02-2004 00:26
stupid question x10 Tom Bottiglieri CD Forum Support 1 04-02-2004 22:40
ill probably feel stupid but i do anyway so... Anthony Kesich Programming 8 05-11-2003 12:53


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

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