I can't remember if I posted this question earlier so I'm sorry if this gets posted twice.
I was wondering about C and namespaces. If I create a function:
int findIndex( int i );
in a.h and in some other file b.h excatly the same signature is used. The function is implemented in a.c and b.c respectively. Either directly or indirectly file a.h includes b.h. Now I have two identical signatures each one refering to a different implentation of the function int findIndex( int i ). In the file a.c I use the funtion findIndex. How does the compiler/linker now know which implentation I refere to? Is there anyway to avoid this problem, if it is a problem? In larger programs it seems to me that it would be impossible to know the names of all declared functions and some function names would proably be used twice. Is this assumption correct?
I have tried testing this with gcc by declaring and implementing a dummy function strlen with excactly the same signature as the strlen function defined in <string.h>. Suprisingly(?) the program changed which function it used depending on where I implemented the dummy function. If implemented the dummy function before I called it, it used the dummy function. If I implemented it after the call the real strlen was used.