Including function definitions (as opposed to declarations) in header files is usually a bad idea, and now you know why. You want two separate files, the header will look like this:
#ifndef TESTF_H_ #define TESTF_H_ extern int test(int); #endif
And then a .c file (or maybe a .m file if you want to use Objective-C, not just C), like this:
int test(int what) { return what; }
The header file will let the compiler know what test , what it returns, and what arguments it should accept; that there is enough information for the compiler to organize the test call; which is actually more information than the compiler needs, but some of us, like our compilers, do some error checking. The C source file (after compilation into an object file) allows the linker to find out what code the test character allows.
Currently, you get several instances of the test symbol visible worldwide, one for each file that includes your testf.h .
source share