linker error help

I am getting a: symbol ‘FIRE_DELAYS’ has multiple definitions

Now the problem is, FIRE_DELAYS is only refrenced two places in my code. they are:


------ fire_control.h -------
#ifndef __fire_control_h_
#define __fire_control_h_
...
const unsigned char FIRE_DELAYS] =
	{75,	/*FIRING*/
 	 200,	/*RETRACTING*/
 	 500};	/*LOADING*/
...
#endif

------ fire control.c -------
#include "fire_control.h"

void FireControl(void){
	...
	if(i < FIRE_DELAYS[fireState -1]){
 	 	...
 	}
 	...
}

Am i just totally overlooking something really obvious, or is the linker behaving oddly.

You’re creating the variable in the .h file. This causes a variable named FIRE_DELAYS to be created in every file which includes your .h file. Instead you want to just create it in one .c file and then declare it extern in the others.

hah. your right. I can’t believe i missed that. Its been a while since i have programmed in anything but java. This whole .h thing takes some getting used to again.