0

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
Aksel Willgert
  • 11,367
  • 5
  • 53
  • 74
  • What is the real question? Just rename/remove the one in your app, include the proper libwebsockets header in its place and move on. 1.don't link with multiple definitions allowed (disabled by default, but if it is enabled in your build, you probably have more problems) 2.namespace functions unless it is a standalone app – technosaurus Jan 02 '14 at 10:52

1 Answers1

0
  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.
unwind
  • 391,730
  • 64
  • 469
  • 606
  • The compiler may not know about the two versions. The linker should though, and it should throw multiple definition errors. – rubenvb Jan 02 '14 at 10:29