core: Explicitly instantiate some Callback class and function templates

This commit is contained in:
Stefano Avallone
2023-03-09 13:03:17 +01:00
committed by Stefano Avallone
parent 25377f43ae
commit 67c81c737e
2 changed files with 13 additions and 0 deletions

View File

@@ -35,6 +35,10 @@
namespace ns3
{
// Explicit instantiation declaration
template Callback<ObjectBase*> MakeCallback<ObjectBase*>(ObjectBase* (*)());
template Callback<ObjectBase*>::Callback();
template class CallbackImpl<ObjectBase*>;
NS_LOG_COMPONENT_DEFINE("ObjectBase");

View File

@@ -335,6 +335,15 @@ class ObjectBase
const AttributeValue& value);
};
// The following explicit template instantiation declarations prevent all the translation
// units including this header file to implicitly instantiate the callbacks class and
// function templates having ObjectBase as template type parameter that are required to be
// instantiated more often (accorging to the ClangBuildAnalyzer tool).
// These classes and functions are explicitly instantiated in object-base.cc
extern template Callback<ObjectBase*> MakeCallback<ObjectBase*>(ObjectBase* (*)());
extern template Callback<ObjectBase*>::Callback();
extern template class CallbackImpl<ObjectBase*>;
} // namespace ns3
#endif /* OBJECT_BASE_H */