From 67c81c737e0be83c0ea77700aa84a257998813a0 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 9 Mar 2023 13:03:17 +0100 Subject: [PATCH] core: Explicitly instantiate some Callback class and function templates --- src/core/model/object-base.cc | 4 ++++ src/core/model/object-base.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/core/model/object-base.cc b/src/core/model/object-base.cc index 65cc54c1f..14d61f81e 100644 --- a/src/core/model/object-base.cc +++ b/src/core/model/object-base.cc @@ -35,6 +35,10 @@ namespace ns3 { +// Explicit instantiation declaration +template Callback MakeCallback(ObjectBase* (*)()); +template Callback::Callback(); +template class CallbackImpl; NS_LOG_COMPONENT_DEFINE("ObjectBase"); diff --git a/src/core/model/object-base.h b/src/core/model/object-base.h index 66aa4be1c..c496531cb 100644 --- a/src/core/model/object-base.h +++ b/src/core/model/object-base.h @@ -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 MakeCallback(ObjectBase* (*)()); +extern template Callback::Callback(); +extern template class CallbackImpl; + } // namespace ns3 #endif /* OBJECT_BASE_H */