I have problem when including same header file from two different source files I get error from duplicate variables.
Variable is defined in PID.h
I have PID.h that is included in PID.c and main.c.
Now I trying to port my code to work in LPCXpresso.
I have been using eclipse and gcc before, and this same code and files has been working in that environment.
./src/main.o:(.bss.PID+0x0): multiple definition of `PID'
AHB_SRAM1: 1048 B 32 KB 3.20%
./src/PID.o:(.bss.PID+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Header files are located in separate holder just to keep thing clean.
It's include path is defined as:
"${workspace_loc:/${ProjName}/inc}"
已解决! 转到解答。
Variable is defined in PID.h
That's the problem. Header files are for *declarations*, not definitions!
You probably missed the 'exern' in the header file, it shall be for example
extern int pid;
in the header file pid.h und
int pid;
in the pid.c
I hope this helps,
Erich
Hello
That is a way that I use header for declarations and in source files variables are defined.
It seems that my old tool chain handled those pit different.
I changed according your advice and now code is build fine.
Thanks
Variable is defined in PID.h
That's the problem. Header files are for *declarations*, not definitions!
You probably missed the 'exern' in the header file, it shall be for example
extern int pid;
in the header file pid.h und
int pid;
in the pid.c
I hope this helps,
Erich