This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Two different functions but with the same name in separate libraries

I have two libraries, named a.lib and b.lib. Both libraries have a function char test(void), but return different characters.

a.c (a.lib)

char test(void);
char test(void) {
return 'a';
}

b.c (b.lib)

char test(void);
char test(void) {
return 'b';
}

I create a project link these two libraries and call test() in main() function.

main.c

char test(void);
int main()
{
char c = test();
return 0;
}

I expected it should be "Error: L6200E: Symbol multiply defined" error, but " 0 errors".

Why is there no link error?

Thanks for the reply.

Parents
  • I wanted to use the function in a.lib and I didn't know b.lib has such a same-name API at first, so I got a wrong result. After checking map file, I found the linker connect to the wrong lib (b.lib). My purpose is to avoid the same situation. If linker can not help this, is there any other method to help? Thanks.

Reply
  • I wanted to use the function in a.lib and I didn't know b.lib has such a same-name API at first, so I got a wrong result. After checking map file, I found the linker connect to the wrong lib (b.lib). My purpose is to avoid the same situation. If linker can not help this, is there any other method to help? Thanks.

Children