The linker complains about multiple
definitions, not
declarations.
If you need to use a symbol (for instance a variable) in multiple sources then you have to:
- Define it in one, single source.
- Declare it, as
extern
in all the other sources (you may include an header file for the purpose).
e.g.:
header file
decl.h
#ifndef _DECL_H_
#define _DECL_H_
extern int global_counter;
#endif
source file
src1.c
int global_counter;
source file
src2.c
#include "decl.h"
int increment()
{
global_counter++;
}
and so on...
:)