I know this question has been asked many times but mine is a little different, or so I like to think.
So I have a .h file I am using for macros and struct definitions and what not. I do have it guarded with the usual...
#ifndef DEFINITIONS_H
#define DEFINITIONS_H
#define some_macro ....
enum TYPE {.,.,.,.,};
typedef struct Blah{
...
...
}Blah_t;
#endif
...and this has worked perfectly fine until I tried to add an array
unsigned char EBCDICtoASCIItable[256] = {... , ... blah blah blah };
Which gets the compile errors: multiple definition of 'EBCDICtoASCIItable', first defined here -> main.o:(.data+0x0)
All of my other header files have the appropriate guards. My .h files only include the necessary .h files. My .c files only include their respective .h file, followed by standard libraries.
The weird thing is I have four sets of .h/.c files that use my definitions.h file and I do not include it in my main.c. Yet, I get four complaints of it already being defined in main.o.
Here is my makefile if that helps...
cbase_deux : main.o fileio.o utilities.o cfgFileManager.o communication.o
gcc -o cbase_deux -g main.o fileio.o utilities.o cfgFileManager.o communication.o
main.o : main.c
gcc -Wall -pedantic -c main.c -g
fileio.o : fileio.c
gcc -Wall -pedantic -c fileio.c -g
utilities.o : utilities.c
gcc -Wall -pedantic -c utilities.c -g
cfgFileManager.o : cfgFileManager.c
gcc -Wall -pedantic -c cfgFileManager.c -g
communication.o : communication.c
gcc -Wall -pedantic -c communication.c -g
clean :
rm cbase_deux main.o fileio.o utilities.o cfgFileManager.o communication.o