pnoltes commented on a change in pull request #293:
URL: https://github.com/apache/celix/pull/293#discussion_r526272524
##########
File path: libs/framework/include/celix/dm/Component_Impl.h
##########
@@ -63,7 +88,7 @@ Component<T>& Component<T>::addInterfaceWithName(const
std::string &serviceName,
template<class T>
template<class I>
-Component<T>& Component<T>::addInterface(const std::string &version, const
Properties &properties) {
+inline Component<T>& Component<T>::addInterface(const std::string &version,
const Properties &properties) {
Review comment:
Removing all inline statements from the C++ dep man implementation,
leads to a lot of errors like:
```
/usr/bin/ld:
CMakeFiles/test_framework.dir/src/bundle_context_services_test.cpp.o: in
function `std::unique_lock<std::mutex>::~unique_lock()':
/home/pep/workspace/celix/libs/framework/include/celix/dm/ServiceDependency_Impl.h:28:
multiple definition of `celix::dm::BaseServiceDependency::runBuild()';
CMakeFiles/test_framework.dir/src/bundle_context_bundles_tests.cpp.o:/home/pep/workspace/celix/libs/framework/include/celix/dm/ServiceDependency_Impl.h:28:
first defined here
```
I read the stackoverflow link, it does not cover everything and I have not
yet found out exactly why this it is needed (I would like to understand it).
Closest I got is:
https://isocpp.org/wiki/faq/templates#separate-template-class-defn-from-decl
As far as I know defining function inside a class will make them implicitly
inline:
https://en.cppreference.com/w/cpp/language/inline
```
A function defined entirely inside a class/struct/union definition, whether
it's a member function or a non-member friend function, is implicitly an inline
function.
```
So defining them outside a class, but still in a header - as is done with
the _Impl.h headers - require a inline statement to make them effectually the
same.
Btw I used the _Imp.h construction, because I really prefer to have clean
declarations of functions, classes, etc without cluttering it with
implementation details.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]