I am coding in the Cypress PSoC IDE (C99 ARM_GCC). When I use an identically named function in two *.c
modules (for example void MyClear()
) I get the error:
Build error: multiple definition of `Clear'
MyClear()
is not mentioned in any header, and I presumed that it is private to the .C
file but I'm obviously wrong.
Point 1:
In C
, functions are global by default.
There is no concept of private
in C
. FWIW, there is static
, however, which limits the scope of the function to the translation unit only . See this previous question and the answers for some clarifiction.
Point 2
You get this error in linking state. When all the translation units have been compiled and about to be linked together, linker can see more than one definition of the function and hence throws the error.
Point to note: You don't define functions in header files. you declare them, and as long as declarations don't conflict, you can have any number of declarations even inside a single translation unit.