Go to Post Hall of Fame FIRST Team 254 has arguably helped more teams become good than any other team in FIRST. I don't think they need a lecture on helping their opponents. - Karthik [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 09-02-2004, 12:39
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Compiler Help Needed

notice that the error you are getting is a link error - this means that the multiple definitions are in different files - are you sure you didn't accidentally name something (even a variable) newValue somewhere else?
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
  #2   Spotlight this post!  
Unread 09-02-2004, 13:25
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Compiler Help Needed

Quote:
Originally Posted by Darkman_X000
Ok, thanks for the info guys, but my problem still isn't fixed. I still get the error about having multiple definitions, even though I don't. I have included the preprocessor directives #ifndef, #define, #endif to prevent such nonsense from bothering me, but to no avail. I have written several functions that I NEED to make my robot work right, and it is extremely frustrating to have the compiler return errors that are unfounded.

Please help!

My code is presented on the previous page, and I don't want to re-post it because it is long... Please check it out and tell me why the function "newValue" keeps coming up as having "multiple definitions"!



Thanx in advance!!!!!!
The code you posted here compiles without a problem.
You need to post or email one of us your whole project as a zip file.
Strip out the project and .o files before you Winzip it if you need to keep the size down.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 10-02-2004, 07:35
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Compiler Help Needed

I don't know. It looks like the only defs are the prototype and the actual code. I would say try putting the prototype in the same file as the sub.
  #4   Spotlight this post!  
Unread 10-02-2004, 11:16
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Compiler Help Needed

Quote:
Originally Posted by Mark McLeod
The code you posted here compiles without a problem.
You need to post or email one of us your whole project as a zip file.
Strip out the project and .o files before you Winzip it if you need to keep the size down.
I second the motion. There must be something going behind the scenes of what you've shown us.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #5   Spotlight this post!  
Unread 10-02-2004, 12:15
Darkman_X000 Darkman_X000 is offline
Registered User
#0612
 
Join Date: Feb 2004
Location: Chantilly, VA
Posts: 8
Darkman_X000 is an unknown quantity at this point
Re: Compiler Help Needed

All right guys, it seems to be working now. I just deleted all #include "userutilities.c" directives and replaced them with #include "userutilities.h" directive where necessary.

So... now I am no longer getting the "multiple definition" errors that were driving me insane. Thanks for your help!!!
  #6   Spotlight this post!  
Unread 07-02-2004, 11:31
Mike Soukup's Avatar
Mike Soukup Mike Soukup is offline
Software guy
FRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Schaumburg, IL
Posts: 797
Mike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond repute
Re: Compiler Help Needed

Quote:
Originally Posted by Darkman_X000
Note: these are the only files that contain the definitions of these functions and varibles. There are NO duplicate names or any of that.
WHAT IS GOING ON!?!?!?!?!?!?!?!?!?
Clearly, including the file multiple times is prevented by the preprocessor #ifndef, #define, #endif statements, but it is acting like it just disregards those...
The problem is actually with the line "extern float axleWidth". Since you're including the header that has the declaration of "axleWidth" there is no need to re-declare it inside your function. 'extern' is only used when you have a global variable defined in another file.

From the names of your variables & the way you use them, it looks like those are values that will never change while your code is being executed, ie a constant. If so, there is no need to use a variable to store the values, use a #define instead:

Code:
#define axelWidth  .725
#define wheelRadius  .105
#define clicksPerRevolution  16
Post more questions if you have them.
  #7   Spotlight this post!  
Unread 07-02-2004, 12:15
Darkman_X000 Darkman_X000 is offline
Registered User
#0612
 
Join Date: Feb 2004
Location: Chantilly, VA
Posts: 8
Darkman_X000 is an unknown quantity at this point
Re: Compiler Help Needed

Ok, I just replaced what I had before with:
Code:
#define axelWidth  .725
#define wheelRadius  .105
#define clicksPerRevolution  16
and I have deleted the externs. Now the compiler has no trouble with "axelWidth". Instead it says:
Code:
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - symbol 'newValue' has multiple definitions.
Errors    : 1

BUILD FAILED: Sat Feb 07 12:05:03 2004
I wrote the function prototype in UserUtilities.h and the actual function definition in UserUtilities.c. There should be no conflicts here because prototypes ARE allowed.

Each time I fix a problem with one function or variable name in the set of files, it has a problem with the next one down the line.

Please consider that because bool.h has the necessary preprocessor statements, including it multiple times should not be a problem... right? Isn't that the primary use of #ifndef, #define, and #endif structures in header files?

I also tried to delete the #include "userutilities.h" line from UserUtilities.c after making the above changes, but then it said that axelWidth and wheelRadius were not defined. Can I use extern with a variable that was #defined?

Here is the updated version of my files:
Code:
UserUtilities.h
#ifndef USERUTILITIES_H
#define USERUTILITIES_H

#include "bool.h"

#define axelWidth .725
#define wheelRadius .105
#define clicksPerRevolution 16

/*float axelWidth = .725;
float wheelRadius = .105;
int clicksPerRevolution = 16;*/

bool newValue(int *staticVar, int dynamicVar);
float thetaDegrees(int c);
float thetaRadians(int c);
float Forward(int c);
void move(float distance);
void turnLeft(float degrees);
void turnRight(float degrees);

#endif

UserUtilities.c
#ifndef USERUTILITIES_C
#define USERUTILITIES_C

#include "bool.h"
#include "UserUtilities.h"

bool newValue(int *staticVar, int dynamicVar)
{
	
	if (*staticVar==dynamicVar)
	{
		*staticVar=dynamicVar;
		return true;
	}
	else
	{	
		return false;
	}
}

float thetaDegrees(int clicks)
{
	clicks*=22.5;
	clicks=clicks*wheelRadius;
	clicks/=(float)axelWidth;
	return clicks; //22.5*(float)wheelRadius*clicks/(float)axelWidth;
}

float thetaRadians(int clicks)
{
	clicks*=3.1415926;
	clicks=clicks*wheelRadius;
	clicks/=8*axelWidth;
	return clicks;
}

#endif
  #8   Spotlight this post!  
Unread 07-02-2004, 21:08
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Compiler Help Needed

Quote:
Originally Posted by Mike Soukup
... From the names of your variables & the way you use them, it looks like those are values that will never change while your code is being executed, ie a constant. If so, there is no need to use a variable to store the values, use a #define instead:

Code:
#define axelWidth  .725
#define wheelRadius  .105
#define clicksPerRevolution  16
...
I, personally, have had problems with #declare in place of const, and only use it for alias, Example:
Code:
//Some constants
const char Varience = 10;
const char True = 255;
const char bLAH = 152;

//Some aliases
#declare Left_OI p1_y
#declare Left_Motor pwm01
#declare DyNoMiTe relay8
As long as you keep it in headers and include them, you should be ok.
  #9   Spotlight this post!  
Unread 07-02-2004, 21:48
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Compiler Help Needed

first of all, it's "#define", not "#declare"

second, the reason you are having problems is because mcc18 automatically casts any number from 0 to 255 as an unsigned char, which can screw up math. instead, what you'd want is this:

#define Varience ((char) 10)
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
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
C compiler for 2004 Tim Skloss Technical Discussion 11 05-11-2003 22:02
C compiler for 2004 Tim Skloss Robotics Education and Curriculum 2 04-11-2003 16:19
The Grand FIRST team.. programmers and others needed randomperson Programming 0 31-05-2003 23:46
Weight needed to tilt bridge... archiver 2001 4 23-06-2002 23:43
Inventor 5.0 help needed Larry Barello Inventor 4 27-01-2002 10:54


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

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