Overlapping function names when integrating 3pp lib in c

183 views Asked by At

Im trying to integrate a third-party library (libwebsockets) into an application.

Now it turned out libwebsockets had the function:

unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);

And the application had a similiar function

char *SHA1(char *string)

Unfortunately libwebsockts during execution used the function in the app instead of its own.

  1. Now what is the canonical way of the detecting situations like this, to make it easier to integrate a 3pp-lib (found this clash after step-debuging alot of lines of code)? (Im using visual studio if there is tricks available in there)

  2. Is it bad design in the app (and/or) the lib that allows this to happen?

1

There are 1 answers

1
unwind On
  1. Situations like this shouldn't happen. There should be compiler errors (or at the very least warnings) happening if you try this. The two functions are not compatible, I don't see how a call to the library's 3-argument SHA1() can ever become a call to your 1-argument version.
  2. It might be something wrong in the build process, or missing declarations elsewhere.