This pull request addresses a critical compilation issue encountered when including <DataFrame/DataFrame.h> in multiple cpp files within our project. The root cause of this problem was identified as the presence of non-template, non-inline functions defined in ThreadPool.tcc, leading to multiple definition errors during the linking stage.
Issue Description
The project failed to compile, throwing multiple definition errors related to various functions within the hmdf::ThreadPool class. These errors were triggered by the linker (/usr/bin/ld) when attempting to compile object files that included the DataFrame.h header. A typical error message was as follows:
/usr/bin/ld: CMakeFiles/StructureBond.dir/test.cpp.o: in function `hmdf::ThreadPool::available_threads() const': test.cpp:(.text+0x80): multiple definition of `hmdf::ThreadPool::available_threads() const'; CMakeFiles/StructureBond.dir/main.cpp.o:main.cpp:(.text+0x4b60): first defined here
Resolution
To resolve this issue, I have added the inline keyword to all non-template functions within ThreadPool.tcc. This ensures that these functions are treated as inline functions, thus preventing the linker from encountering multiple definitions across different translation units. This is a standard solution for such issues as per the C++ One Definition Rule (ODR).
Description
This pull request addresses a critical compilation issue encountered when including
<DataFrame/DataFrame.h>
in multiple cpp files within our project. The root cause of this problem was identified as the presence of non-template, non-inline functions defined in ThreadPool.tcc, leading to multiple definition errors during the linking stage.Issue Description
The project failed to compile, throwing multiple definition errors related to various functions within the hmdf::ThreadPool class. These errors were triggered by the linker (/usr/bin/ld) when attempting to compile object files that included the DataFrame.h header. A typical error message was as follows:
Resolution
To resolve this issue, I have added the inline keyword to all non-template functions within ThreadPool.tcc. This ensures that these functions are treated as inline functions, thus preventing the linker from encountering multiple definitions across different translation units. This is a standard solution for such issues as per the C++ One Definition Rule (ODR).