0

I have a poorly designed library that has implementations of non-inline functions in a header file.

My project which has to use the library relies on it, but it produces duplicate definitions of all the non-inlinefunctions in the header file upon linking.

An easy fix is to declare the functions inline and compile as usual, an even better fix is to move the implementation files to their own .cpp files and compile the rest as a library.

So my question is twofold: 1) If I declare the functions inline, will it affect their behaviour, i.e. is it possible that a name collision might not be occuring normally but will after I declare the functions inline. e.g. can it make them not-thread-safe. 2) (Optional) Is there a textbook or a detailed guide to compiling dynamically linked libraries under Linux/OS X.

Alex Petrosyan
  • 473
  • 2
  • 20
  • Related: [this](https://stackoverflow.com/q/1759300/3871028) and [this](https://stackoverflow.com/q/145838/3871028) – Ripi2 Aug 10 '18 at 17:38
  • Reminder: the `inline` keyword is a suggestion to the compiler. The compiler may ignore it when higher optimizations are selected. – Thomas Matthews Aug 10 '18 at 17:44
  • @ThomasMatthews, so it should preserve the exact behaviour of the function, or am I wrong. – Alex Petrosyan Aug 10 '18 at 17:45
  • 1
    It will preserve functional behavior as far as the C++ standard. You may lose some debug ability to detect call/return behavior. – stark Aug 10 '18 at 17:47
  • @ThomasMatthews The `inline` is not as much for the compiler as it is a linker keyword! –  Aug 10 '18 at 21:25

0 Answers0