I know there are a lot of questions on this topic, and I\'ve looked through a fair number of them. However I am still having problems.
I started writing a test prog
Adding library files to a solution should be simple. Go to the Solution Explorer, right-click on your solution, and go to "Add->Existing Item". If you want to add a pre-existing library and keep it in a separate folder from your solution, click the arrow next to "Add" and choose "Add as link". That saves many headaches due to having a duplicate copy of your library in your solution folder, and files not staying up-to-date.
You are right in saying that you need to include the necessary header files in the .c
files where they are used.
The compiler compiles each C file separately, and then links them together at the end, so you got the error unknown typename int_*
because the compiler had not seen the relevant header in the context of compiling that C file.
You also seem to be in some confusion as to the difference between definition and declaration.
A function is:
int some_func(char some_var);
which tells the compiler that the function exists, but does not tell it what it is. This is necessary because the compiler only looks at one C file at a time, so needs to be told that other functions exist.int some_func(char some_var) { do_stuff(some_var); }
. After compilation of each individual C file in isolation, the linker is called to put all the pieces together and give you your final binary, which you flash to the device.A function can be (and must be) defined only once, but may be declared many times - even in the same file, so long as the declarations are not conflicting.