I guess that you are on a Posix system (Linux, MacOSX...)
I assume that your two source files program1.c and program2.c corresponds to two different executables program1 and program2
Make a header file myheader.h containing types, function & variable declarations.
Make an implementation file common.c containing the common functions (and common variables) definitions
Add #include "myheader.h" inside all of program1.c, program2.c, common.c
compile common.c to an object file common.o:
gcc -Wall -g -c common.c -o common.o
compile each of program1.c and program2.c and link it to that object file common.o
gcc -Wall -g program1.c common.o -o program1
gcc -Wall -g program2.c common.o -o program2
Later, learn how to make a program library -e.g. a static library libcommon.a or a shared library libcommon.so - (read this howto) and use a builder like make (see this documentation, and also this example). Your library could contain several members common_a.o and common_b.o ....