View Single Post
  #1   Spotlight this post!  
Unread 07-02-2004, 11:16
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
Compiler Help Needed

Ok guys, what is the deal!? I am getting the following errors when I compile:
Code:
OUTPUT
MPLINK 3.40, Linker
Copyright (c) 2003 Microchip Technology Inc.
Error - symbol 'axelWidth' has multiple definitions.
Errors    : 1

BUILD FAILED: Sat Feb 07 11:04:01 2004
This is really annoying because it does not tell me where the other definitions are. In C++, and in this compiler, if I define the same thing twice explicitly, it tells me where the previous definition is. Here is a sample of my code:
Code:
UserUtilities.h
#ifndef USERUTILITIES_H
#define USERUTILITIES_H

#include "bool.h"

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);

#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)
{
	extern float axelWidth;
	extern float wheelRadius;
	clicks*=22.5;
	clicks=clicks*wheelRadius;
	clicks/=(float)axelWidth;
	return clicks; //22.5*(float)wheelRadius*clicks/(float)axelWidth;
}

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

#endif
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...