View Single Post
  #4   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