Your first problem is, as suggested in my comment, that you include a source file. You only include headers so the prototypes are there and the code compiles, but you don't include the other code files - these are compiled seperately. Not doing so ruins the only advantage seperate compilation has, faster recompilation since only a few source files change between each compilation and unchanged files don't need to be compiled again because the .obj files are still there.
Fixing that, your problem should disappear. But not forever, only as long as the project stays that small and you don't include anything multiple times. Every header file (well, every file you included - but that's only headers) must have an "include guard", which prevents the file from being included multiple times (remember, #include "file"
only means "paste the contents of file
here before compiling") - main.c
includes definitions.h
and functions.c
, but functions.c
also includes definitions.h
, so the contents of definitions.h
get included twice, hence all types and function prototypes are in fact defined twice - which is illegal. At the very beginning of each header file, put something like this:
#ifndef UNIQUE_HEADER_NAME_H
#define UNIQUE_HEADER_NAME_H
And at the very end, put an #endif
(some prefer #endif //UNIQUE_HEADER_NAME_H
after the endif, for clarify). So when the file is first included, UNIQUE_HEADER_NAME_H
is not defined, therefore the file gets included as normal and UNIQUE_HEADER_NAME_H
gets defined. And the next time it is included, UNIQUE_HEADER_NAME_H
is already definded, thus the preprocessor skips to the matching endif (the one at the end, unless you missed one in the actual header) and nothing gets included twice.