|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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?
|
|
#2
|
|||||
|
|||||
|
Re: Compiler Help Needed
Quote:
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. |
|
#3
|
|||||
|
|||||
|
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
|
|||||
|
|||||
|
Re: Compiler Help Needed
Quote:
|
|
#5
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Compiler Help Needed
Quote:
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 |
|
#7
|
|||
|
|||
|
Re: Compiler Help Needed
Ok, I just replaced what I had before with:
Code:
#define axelWidth .725 #define wheelRadius .105 #define clicksPerRevolution 16 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 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
|
|||||
|
|||||
|
Re: Compiler Help Needed
Quote:
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 |
|
#9
|
||||
|
||||
|
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) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |