Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   linker error help (http://www.chiefdelphi.com/forums/showthread.php?t=43933)

Rickertsen2 13-02-2006 17:37

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:
Code:

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

Dave Flowerday 13-02-2006 17:47

Re: linker error help
 
Quote:

Originally Posted by Rickertsen2
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.

Rickertsen2 13-02-2006 17:53

Re: linker error help
 
Quote:

Originally Posted by Dave Flowerday
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.


All times are GMT -5. The time now is 01:34.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi