You should never not define global variables in header files. You can declare them as extern in header file and define them in a .c source file.
Suppose if you define a variable called int my_int
in header file my_header.h
and you system has more then one .c file called file1.c and file2.c both are including my_header.h
. Then variable my_int
would be declared twice and can create unexpected result. Better approach would be to define my_int
in one of the .c file and create the exterm int my_int in the header file.
I hope it should help you.