Hi All
I need some guidance with header files because I can't solve the following compile error:
Code:
make
gcc -I./lib -c file1.c -o file1.o
gcc -I./lib -c file2.c -o file2.o
gcc -I./lib -c file.c -o file.o
gcc -Wall -g -fast -o stats file1.o file2.o file.o -L./lib -lmyconfig
ld: duplicate symbol _default_keys in file.o and file1.o
collect2: ld returned 1 exit status
make: *** [stats] Error 1
Both file.c and file1.c include libmyconfig.h and file.c includes file1.h.
libmyconfig.h looks (simplyfied) like
Code:
void check_config_file(char *file) ;
int load_config_file(char *filename) ;
struct CONFIG
{
int *var1 ;
char *var2 ;
} ;
char *default_keys[] = {"var1", "var2"} ;
char *default_values[] = {"10", "20"} ;
So, default_keys is included twice. I tried to solve this by adding ifndef .... endif:
Code:
#ifndef BLA
#define BLA
.....
#endif
Unfortunately it didn't change anything Any suggestions why?