Below are two files which I will use as my example. If I define an array of structures in file1.h and have file2.c include file1.h I would get a multiple definition error. Why is that? If I just have struct thread tasks[32] I don’t get this error.
file1.h
...
...
struct thread tasks[32] = {0}; // thread is structure defined above
...
...
file2.c
#include file1.h
Most likely you are including the header file in more than one source file. The
#includedirective literally includes the contents of the header file into the source file, which means that all code in the header file will also be in the source file. This means that if two or more source file includes the same header file then the code in the header file will be duplicated.