Add -Wextra-semi -Wundefined-func-template to the default CXXFLAGS

And fix the resulting compilation errors.

Change-Id: I16f679836a0cf2a3ff5dfcf6f6b67bfbfe4cdbd7
Refs: #4248
diff --git a/src/data.cpp b/src/data.cpp
index e982700..9a59089 100644
--- a/src/data.cpp
+++ b/src/data.cpp
@@ -84,12 +84,10 @@
 }
 
 template size_t
-Data::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder,
-                                       bool wantUnsignedPortionOnly) const;
+Data::wireEncode<encoding::EncoderTag>(EncodingBuffer&, bool) const;
 
 template size_t
-Data::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder,
-                                         bool wantUnsignedPortionOnly) const;
+Data::wireEncode<encoding::EstimatorTag>(EncodingEstimator&, bool) const;
 
 const Block&
 Data::wireEncode(EncodingBuffer& encoder, const Block& signatureValue) const
diff --git a/src/data.hpp b/src/data.hpp
index eedea7a..2729e0d 100644
--- a/src/data.hpp
+++ b/src/data.hpp
@@ -241,6 +241,14 @@
   mutable Name m_fullName; ///< cached FullName computed from m_wire
 };
 
+#ifndef DOXYGEN
+extern template size_t
+Data::wireEncode<encoding::EncoderTag>(EncodingBuffer&, bool) const;
+
+extern template size_t
+Data::wireEncode<encoding::EstimatorTag>(EncodingEstimator&, bool) const;
+#endif
+
 std::ostream&
 operator<<(std::ostream& os, const Data& data);
 
diff --git a/src/delegation-list.cpp b/src/delegation-list.cpp
index 7868943..e21d100 100644
--- a/src/delegation-list.cpp
+++ b/src/delegation-list.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -105,10 +105,10 @@
 }
 
 template size_t
-DelegationList::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&, uint32_t) const;
+DelegationList::wireEncode<encoding::EncoderTag>(EncodingBuffer&, uint32_t) const;
 
 template size_t
-DelegationList::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&, uint32_t) const;
+DelegationList::wireEncode<encoding::EstimatorTag>(EncodingEstimator&, uint32_t) const;
 
 void
 DelegationList::wireDecode(const Block& block, bool wantSort)
diff --git a/src/delegation-list.hpp b/src/delegation-list.hpp
index b9eb6a9..a5cf58a 100644
--- a/src/delegation-list.hpp
+++ b/src/delegation-list.hpp
@@ -232,6 +232,14 @@
   friend bool operator==(const DelegationList&, const DelegationList&);
 };
 
+#ifndef DOXYGEN
+extern template size_t
+DelegationList::wireEncode<encoding::EncoderTag>(EncodingBuffer&, uint32_t) const;
+
+extern template size_t
+DelegationList::wireEncode<encoding::EstimatorTag>(EncodingEstimator&, uint32_t) const;
+#endif
+
 /** \brief compare whether two DelegationLists are equal
  *  \note Order matters! If two DelegationLists contain the same Delegations but at least one is
  *        unsorted, they may compare unequal if the Delegations appear in different order.
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 031b00f..177d1f2 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -24,11 +24,9 @@
 #ifndef NDN_ENCODING_BLOCK_HPP
 #define NDN_ENCODING_BLOCK_HPP
 
-#include "../common.hpp"
-
 #include "buffer.hpp"
-#include "tlv.hpp"
 #include "encoding-buffer-fwd.hpp"
+#include "tlv.hpp"
 
 namespace boost {
 namespace asio {
diff --git a/src/encoding/encoding-buffer-fwd.hpp b/src/encoding/encoding-buffer-fwd.hpp
index 359864f..88f6dea 100644
--- a/src/encoding/encoding-buffer-fwd.hpp
+++ b/src/encoding/encoding-buffer-fwd.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,10 +22,12 @@
 #ifndef NDN_ENCODING_ENCODING_BUFFER_FWD_HPP
 #define NDN_ENCODING_ENCODING_BUFFER_FWD_HPP
 
+#include "../common.hpp"
+
 namespace ndn {
 namespace encoding {
 
-typedef bool Tag;
+using Tag = bool;
 
 /**
  * @brief Tag for EncodingImpl to indicate that Encoder is requested
@@ -44,8 +46,8 @@
 template<Tag TAG>
 class EncodingImpl;
 
-typedef EncodingImpl<EncoderTag> EncodingBuffer;
-typedef EncodingImpl<EstimatorTag> EncodingEstimator;
+using EncodingBuffer    = EncodingImpl<EncoderTag>;
+using EncodingEstimator = EncodingImpl<EstimatorTag>;
 
 } // namespace encoding
 
@@ -55,4 +57,16 @@
 
 } // namespace ndn
 
+#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName) \
+  extern template size_t \
+  ClassName::wireEncode<::ndn::encoding::EncoderTag>(::ndn::EncodingBuffer&) const; \
+  extern template size_t \
+  ClassName::wireEncode<::ndn::encoding::EstimatorTag>(::ndn::EncodingEstimator&) const \
+
+#define NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ClassName) \
+  template size_t \
+  ClassName::wireEncode<::ndn::encoding::EncoderTag>(::ndn::EncodingBuffer&) const; \
+  template size_t \
+  ClassName::wireEncode<::ndn::encoding::EstimatorTag>(::ndn::EncodingEstimator&) const \
+
 #endif // NDN_ENCODING_ENCODING_BUFFER_FWD_HPP
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index 4f364fe..9b483c2 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -22,7 +22,6 @@
 #ifndef NDN_ENCODING_ENCODING_BUFFER_HPP
 #define NDN_ENCODING_ENCODING_BUFFER_HPP
 
-#include "../common.hpp"
 #include "encoding-buffer-fwd.hpp"
 #include "encoder.hpp"
 #include "estimator.hpp"
@@ -31,10 +30,10 @@
 namespace encoding {
 
 /**
- * @brief EncodingImpl specialization for real TLV encoding
+ * @brief EncodingImpl specialization for actual TLV encoding
  */
 template<>
-class EncodingImpl<EncoderTag> : public encoding::Encoder
+class EncodingImpl<EncoderTag> : public Encoder
 {
 public:
   explicit
@@ -51,10 +50,10 @@
 };
 
 /**
- * @brief EncodingImpl specialization TLV size estimation
+ * @brief EncodingImpl specialization for TLV size estimation
  */
 template<>
-class EncodingImpl<EstimatorTag> : public encoding::Estimator
+class EncodingImpl<EstimatorTag> : public Estimator
 {
 public:
   explicit
diff --git a/src/exclude.cpp b/src/exclude.cpp
index 900d933..f352948 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -144,11 +144,7 @@
   return totalLength;
 }
 
-template size_t
-Exclude::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Exclude::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Exclude);
 
 const Block&
 Exclude::wireEncode() const
diff --git a/src/exclude.hpp b/src/exclude.hpp
index e3494f2..0bd6155 100644
--- a/src/exclude.hpp
+++ b/src/exclude.hpp
@@ -132,7 +132,7 @@
   bool
   operator!=(const Exclude& other) const;
 
-public: // interal storage
+public: // internal storage
   /**
    * @brief either a name::Component or "negative infinity"
    */
@@ -292,8 +292,7 @@
   operator<<(std::ostream& os, const Exclude& name);
 };
 
-std::ostream&
-operator<<(std::ostream& os, const Exclude& name);
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude);
 
 bool
 operator==(const Exclude::ExcludeComponent& a, const Exclude::ExcludeComponent& b);
@@ -304,6 +303,9 @@
 std::ostream&
 operator<<(std::ostream& os, const Exclude::Range& range);
 
+std::ostream&
+operator<<(std::ostream& os, const Exclude& name);
+
 inline Exclude::const_iterator
 Exclude::begin() const
 {
diff --git a/src/interest.cpp b/src/interest.cpp
index 26b564e..60e284b 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -97,11 +97,7 @@
   return totalLength;
 }
 
-template size_t
-Interest::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Interest::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Interest);
 
 const Block&
 Interest::wireEncode() const
diff --git a/src/interest.hpp b/src/interest.hpp
index 121541b..52cabf7 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -338,6 +338,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Interest);
+
 std::ostream&
 operator<<(std::ostream& os, const Interest& interest);
 
diff --git a/src/key-locator.cpp b/src/key-locator.cpp
index 8eef8cc..50453d9 100644
--- a/src/key-locator.cpp
+++ b/src/key-locator.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -74,11 +74,7 @@
   return totalLength;
 }
 
-template size_t
-KeyLocator::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-KeyLocator::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(KeyLocator);
 
 const Block&
 KeyLocator::wireEncode() const
diff --git a/src/key-locator.hpp b/src/key-locator.hpp
index b442854..50e4b99 100644
--- a/src/key-locator.hpp
+++ b/src/key-locator.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -162,6 +162,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(KeyLocator);
+
 std::ostream&
 operator<<(std::ostream& os, const KeyLocator& keyLocator);
 
diff --git a/src/lp/cache-policy.cpp b/src/lp/cache-policy.cpp
index 37dad5e..aea7d05 100644
--- a/src/lp/cache-policy.cpp
+++ b/src/lp/cache-policy.cpp
@@ -59,19 +59,15 @@
   if (m_policy == CachePolicyType::NONE) {
     BOOST_THROW_EXCEPTION(Error("CachePolicyType must be set"));
   }
+
   size_t length = 0;
-  length += prependNonNegativeIntegerBlock(encoder, tlv::CachePolicyType,
-                                           static_cast<uint32_t>(m_policy));
+  length += prependNonNegativeIntegerBlock(encoder, tlv::CachePolicyType, static_cast<uint32_t>(m_policy));
   length += encoder.prependVarNumber(length);
   length += encoder.prependVarNumber(tlv::CachePolicy);
   return length;
 }
 
-template size_t
-CachePolicy::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-CachePolicy::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(CachePolicy);
 
 const Block&
 CachePolicy::wireEncode() const
diff --git a/src/lp/cache-policy.hpp b/src/lp/cache-policy.hpp
index 45b9493..f35dc06 100644
--- a/src/lp/cache-policy.hpp
+++ b/src/lp/cache-policy.hpp
@@ -103,6 +103,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CachePolicy);
+
 } // namespace lp
 } // namespace ndn
 
diff --git a/src/lp/nack-header.cpp b/src/lp/nack-header.cpp
index 9f3157c..3bbc985 100644
--- a/src/lp/nack-header.cpp
+++ b/src/lp/nack-header.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -61,18 +61,13 @@
 NackHeader::wireEncode(EncodingImpl<TAG>& encoder) const
 {
   size_t length = 0;
-  length += prependNonNegativeIntegerBlock(encoder, tlv::NackReason,
-                                           static_cast<uint32_t>(m_reason));
+  length += prependNonNegativeIntegerBlock(encoder, tlv::NackReason, static_cast<uint32_t>(m_reason));
   length += encoder.prependVarNumber(length);
   length += encoder.prependVarNumber(tlv::Nack);
   return length;
 }
 
-template size_t
-NackHeader::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-NackHeader::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(NackHeader);
 
 const Block&
 NackHeader::wireEncode() const
diff --git a/src/lp/nack-header.hpp b/src/lp/nack-header.hpp
index 4544f54..0c034f4 100644
--- a/src/lp/nack-header.hpp
+++ b/src/lp/nack-header.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -87,7 +87,9 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NackHeader);
+
 } // namespace lp
 } // namespace ndn
 
-#endif // NDN_CXX_LP_NACK_HEADER_HPP
\ No newline at end of file
+#endif // NDN_CXX_LP_NACK_HEADER_HPP
diff --git a/src/meta-info.cpp b/src/meta-info.cpp
index dcafb18..e19c11d 100644
--- a/src/meta-info.cpp
+++ b/src/meta-info.cpp
@@ -152,8 +152,7 @@
 
   // FreshnessPeriod
   if (m_freshnessPeriod != DEFAULT_FRESHNESS_PERIOD) {
-    totalLength += prependNonNegativeIntegerBlock(encoder, tlv::FreshnessPeriod,
-                                                  m_freshnessPeriod.count());
+    totalLength += prependNonNegativeIntegerBlock(encoder, tlv::FreshnessPeriod, m_freshnessPeriod.count());
   }
 
   // ContentType
@@ -166,11 +165,7 @@
   return totalLength;
 }
 
-template size_t
-MetaInfo::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-MetaInfo::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(MetaInfo);
 
 const Block&
 MetaInfo::wireEncode() const
diff --git a/src/meta-info.hpp b/src/meta-info.hpp
index bec2275..e8e8a00 100644
--- a/src/meta-info.hpp
+++ b/src/meta-info.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,11 +22,11 @@
 #ifndef NDN_META_INFO_HPP
 #define NDN_META_INFO_HPP
 
-#include "common.hpp"
 #include "encoding/block.hpp"
 #include "encoding/encoding-buffer.hpp"
-#include "util/time.hpp"
 #include "name-component.hpp"
+#include "util/time.hpp"
+
 #include <list>
 
 namespace ndn {
@@ -198,11 +198,11 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(MetaInfo);
+
 std::ostream&
 operator<<(std::ostream& os, const MetaInfo& info);
 
-/////////////////////////////////////////////////////////////////////////
-
 inline uint32_t
 MetaInfo::getType() const
 {
diff --git a/src/mgmt/nfd/channel-status.cpp b/src/mgmt/nfd/channel-status.cpp
index e6e53f4..5fd93b1 100644
--- a/src/mgmt/nfd/channel-status.cpp
+++ b/src/mgmt/nfd/channel-status.cpp
@@ -47,11 +47,7 @@
   return totalLength;
 }
 
-template size_t
-ChannelStatus::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const;
-
-template size_t
-ChannelStatus::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus);
 
 const Block&
 ChannelStatus::wireEncode() const
diff --git a/src/mgmt/nfd/channel-status.hpp b/src/mgmt/nfd/channel-status.hpp
index 04b3ed6..0345550 100644
--- a/src/mgmt/nfd/channel-status.hpp
+++ b/src/mgmt/nfd/channel-status.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -76,6 +76,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus);
+
 bool
 operator==(const ChannelStatus& a, const ChannelStatus& b);
 
diff --git a/src/mgmt/nfd/control-parameters.cpp b/src/mgmt/nfd/control-parameters.cpp
index 465482f..61fb823 100644
--- a/src/mgmt/nfd/control-parameters.cpp
+++ b/src/mgmt/nfd/control-parameters.cpp
@@ -92,11 +92,7 @@
   return totalLength;
 }
 
-template size_t
-ControlParameters::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const;
-
-template size_t
-ControlParameters::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ControlParameters);
 
 Block
 ControlParameters::wireEncode() const
diff --git a/src/mgmt/nfd/control-parameters.hpp b/src/mgmt/nfd/control-parameters.hpp
index c4d2167..791813f 100644
--- a/src/mgmt/nfd/control-parameters.hpp
+++ b/src/mgmt/nfd/control-parameters.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -484,6 +484,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ControlParameters);
+
 std::ostream&
 operator<<(std::ostream& os, const ControlParameters& parameters);
 
diff --git a/src/mgmt/nfd/face-event-notification.cpp b/src/mgmt/nfd/face-event-notification.cpp
index 79a94f2..653a9d9 100644
--- a/src/mgmt/nfd/face-event-notification.cpp
+++ b/src/mgmt/nfd/face-event-notification.cpp
@@ -61,11 +61,7 @@
   return totalLength;
 }
 
-template size_t
-FaceEventNotification::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-FaceEventNotification::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(FaceEventNotification);
 
 const Block&
 FaceEventNotification::wireEncode() const
diff --git a/src/mgmt/nfd/face-event-notification.hpp b/src/mgmt/nfd/face-event-notification.hpp
index 1c6ae4c..c933fbf 100644
--- a/src/mgmt/nfd/face-event-notification.hpp
+++ b/src/mgmt/nfd/face-event-notification.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -70,6 +70,8 @@
   FaceEventKind m_kind;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceEventNotification);
+
 bool
 operator==(const FaceEventNotification& a, const FaceEventNotification& b);
 
diff --git a/src/mgmt/nfd/face-query-filter.cpp b/src/mgmt/nfd/face-query-filter.cpp
index 6bde1d4..5204aa9 100644
--- a/src/mgmt/nfd/face-query-filter.cpp
+++ b/src/mgmt/nfd/face-query-filter.cpp
@@ -83,11 +83,7 @@
   return totalLength;
 }
 
-template size_t
-FaceQueryFilter::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const;
-
-template size_t
-FaceQueryFilter::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(FaceQueryFilter);
 
 const Block&
 FaceQueryFilter::wireEncode() const
diff --git a/src/mgmt/nfd/face-query-filter.hpp b/src/mgmt/nfd/face-query-filter.hpp
index b0e9e5d..4b35293 100644
--- a/src/mgmt/nfd/face-query-filter.hpp
+++ b/src/mgmt/nfd/face-query-filter.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -218,6 +218,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceQueryFilter);
+
 bool
 operator==(const FaceQueryFilter& a, const FaceQueryFilter& b);
 
diff --git a/src/mgmt/nfd/face-status.cpp b/src/mgmt/nfd/face-status.cpp
index 1cfc741..360865a 100644
--- a/src/mgmt/nfd/face-status.cpp
+++ b/src/mgmt/nfd/face-status.cpp
@@ -79,11 +79,7 @@
   return totalLength;
 }
 
-template size_t
-FaceStatus::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-FaceStatus::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus);
 
 const Block&
 FaceStatus::wireEncode() const
diff --git a/src/mgmt/nfd/face-status.hpp b/src/mgmt/nfd/face-status.hpp
index d34973a..aa7accb 100644
--- a/src/mgmt/nfd/face-status.hpp
+++ b/src/mgmt/nfd/face-status.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -161,6 +161,8 @@
   uint64_t m_nOutBytes;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus);
+
 bool
 operator==(const FaceStatus& a, const FaceStatus& b);
 
diff --git a/src/mgmt/nfd/fib-entry.cpp b/src/mgmt/nfd/fib-entry.cpp
index db3b69f..ef47f6a 100644
--- a/src/mgmt/nfd/fib-entry.cpp
+++ b/src/mgmt/nfd/fib-entry.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -74,11 +74,7 @@
   return totalLength;
 }
 
-template size_t
-NextHopRecord::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-NextHopRecord::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(NextHopRecord);
 
 const Block&
 NextHopRecord::wireEncode() const
@@ -190,11 +186,7 @@
   return totalLength;
 }
 
-template size_t
-FibEntry::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-FibEntry::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(FibEntry);
 
 const Block&
 FibEntry::wireEncode() const
diff --git a/src/mgmt/nfd/fib-entry.hpp b/src/mgmt/nfd/fib-entry.hpp
index fa609ef..d91f651 100644
--- a/src/mgmt/nfd/fib-entry.hpp
+++ b/src/mgmt/nfd/fib-entry.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -84,6 +84,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NextHopRecord);
+
 bool
 operator==(const NextHopRecord& a, const NextHopRecord& b);
 
@@ -165,6 +167,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FibEntry);
+
 bool
 operator==(const FibEntry& a, const FibEntry& b);
 
diff --git a/src/mgmt/nfd/forwarder-status.cpp b/src/mgmt/nfd/forwarder-status.cpp
index 50eac63..27f506e 100644
--- a/src/mgmt/nfd/forwarder-status.cpp
+++ b/src/mgmt/nfd/forwarder-status.cpp
@@ -78,11 +78,7 @@
   return totalLength;
 }
 
-template size_t
-ForwarderStatus::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const;
-
-template size_t
-ForwarderStatus::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus);
 
 const Block&
 ForwarderStatus::wireEncode() const
diff --git a/src/mgmt/nfd/forwarder-status.hpp b/src/mgmt/nfd/forwarder-status.hpp
index d751165..d493048 100644
--- a/src/mgmt/nfd/forwarder-status.hpp
+++ b/src/mgmt/nfd/forwarder-status.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -219,6 +219,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus);
+
 bool
 operator==(const ForwarderStatus& a, const ForwarderStatus& b);
 
diff --git a/src/mgmt/nfd/rib-entry.cpp b/src/mgmt/nfd/rib-entry.cpp
index 475af15..c4c2d82 100644
--- a/src/mgmt/nfd/rib-entry.cpp
+++ b/src/mgmt/nfd/rib-entry.cpp
@@ -118,11 +118,7 @@
   return totalLength;
 }
 
-template size_t
-Route::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-Route::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Route);
 
 const Block&
 Route::wireEncode() const
@@ -269,11 +265,7 @@
   return totalLength;
 }
 
-template size_t
-RibEntry::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const;
-
-template size_t
-RibEntry::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(RibEntry);
 
 const Block&
 RibEntry::wireEncode() const
diff --git a/src/mgmt/nfd/rib-entry.hpp b/src/mgmt/nfd/rib-entry.hpp
index e515e64..1ea73d3 100644
--- a/src/mgmt/nfd/rib-entry.hpp
+++ b/src/mgmt/nfd/rib-entry.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -131,6 +131,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Route);
+
 bool
 operator==(const Route& a, const Route& b);
 
@@ -217,6 +219,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(RibEntry);
+
 bool
 operator==(const RibEntry& a, const RibEntry& b);
 
diff --git a/src/mgmt/nfd/strategy-choice.cpp b/src/mgmt/nfd/strategy-choice.cpp
index 4c9ce37..e0496d6 100644
--- a/src/mgmt/nfd/strategy-choice.cpp
+++ b/src/mgmt/nfd/strategy-choice.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -51,11 +51,7 @@
   return totalLength;
 }
 
-template size_t
-StrategyChoice::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const;
-
-template size_t
-StrategyChoice::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(StrategyChoice);
 
 const Block&
 StrategyChoice::wireEncode() const
diff --git a/src/mgmt/nfd/strategy-choice.hpp b/src/mgmt/nfd/strategy-choice.hpp
index ba840f0..55871bb 100644
--- a/src/mgmt/nfd/strategy-choice.hpp
+++ b/src/mgmt/nfd/strategy-choice.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -87,6 +87,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(StrategyChoice);
+
 bool
 operator==(const StrategyChoice& a, const StrategyChoice& b);
 
diff --git a/src/name-component.cpp b/src/name-component.cpp
index 6bccced..1cdd8f9 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -444,7 +444,6 @@
   return encoder.block();
 }
 
-
 template<encoding::Tag TAG>
 size_t
 Component::wireEncode(EncodingImpl<TAG>& encoder) const
@@ -457,11 +456,7 @@
   return totalLength;
 }
 
-template size_t
-Component::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Component::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Component);
 
 const Block&
 Component::wireEncode() const
diff --git a/src/name-component.hpp b/src/name-component.hpp
index 315ea0e..c537eb1 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -567,6 +567,8 @@
   // Block can be reinterpret_cast'ed as Component type.
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Component);
+
 inline std::ostream&
 operator<<(std::ostream& os, const Component& component)
 {
diff --git a/src/name.cpp b/src/name.cpp
index 6dc735f..d80fecf 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -140,11 +140,7 @@
   return totalLength;
 }
 
-template size_t
-Name::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Name::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Name);
 
 const Block&
 Name::wireEncode() const
diff --git a/src/name.hpp b/src/name.hpp
index 890451f..a2efe1b 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -540,6 +540,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Name);
+
 inline bool
 operator==(const Name& lhs, const Name& rhs)
 {
diff --git a/src/net/detail/network-monitor-impl-rtnl.cpp b/src/net/detail/network-monitor-impl-rtnl.cpp
index 71274a1..dbc6815 100644
--- a/src/net/detail/network-monitor-impl-rtnl.cpp
+++ b/src/net/detail/network-monitor-impl-rtnl.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -154,24 +154,24 @@
 static const char*
 nlmsgTypeToString(uint16_t type)
 {
-#define NDN_NLMSG_STRING(x) case NLMSG_##x: return "<" #x ">"
-#define NDN_RTM_STRING(x) case RTM_##x: return "<" #x ">"
+#define NLMSG_STRINGIFY(x) case NLMSG_##x: return "<" #x ">"
+#define RTM_STRINGIFY(x) case RTM_##x: return "<" #x ">"
   switch (type) {
-    NDN_NLMSG_STRING(NOOP);
-    NDN_NLMSG_STRING(ERROR);
-    NDN_NLMSG_STRING(DONE);
-    NDN_NLMSG_STRING(OVERRUN);
-    NDN_RTM_STRING(NEWLINK);
-    NDN_RTM_STRING(DELLINK);
-    NDN_RTM_STRING(NEWADDR);
-    NDN_RTM_STRING(DELADDR);
-    NDN_RTM_STRING(NEWROUTE);
-    NDN_RTM_STRING(DELROUTE);
+    NLMSG_STRINGIFY(NOOP);
+    NLMSG_STRINGIFY(ERROR);
+    NLMSG_STRINGIFY(DONE);
+    NLMSG_STRINGIFY(OVERRUN);
+    RTM_STRINGIFY(NEWLINK);
+    RTM_STRINGIFY(DELLINK);
+    RTM_STRINGIFY(NEWADDR);
+    RTM_STRINGIFY(DELADDR);
+    RTM_STRINGIFY(NEWROUTE);
+    RTM_STRINGIFY(DELROUTE);
     default:
       return "";
   }
-#undef NDN_NLMSG_STRING
-#undef NDN_RTM_STRING
+#undef NLMSG_STRINGIFY
+#undef RTM_STRINGIFY
 }
 
 static InterfaceType
diff --git a/src/security/detail/openssl.hpp b/src/security/detail/openssl.hpp
index cde9efc..99d20cb 100644
--- a/src/security/detail/openssl.hpp
+++ b/src/security/detail/openssl.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -22,15 +22,11 @@
 #ifndef NDN_SECURITY_DETAIL_OPENSSL_HPP
 #define NDN_SECURITY_DETAIL_OPENSSL_HPP
 
-// suppress deprecation warnings in OSX >= 10.7
-
-#if defined(__APPLE__)
-
-#ifdef __clang__
+// suppress deprecation warnings on macOS >= 10.7
+#if defined(__APPLE__) && defined(__clang__)
+#pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#endif // __clang__
-
-#endif // __APPLE__
+#endif
 
 #include <openssl/bio.h>
 #include <openssl/crypto.h>
@@ -43,4 +39,8 @@
 #include <openssl/rsa.h>
 #include <openssl/x509.h>
 
+#if defined(__APPLE__) && defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 #endif // NDN_SECURITY_DETAIL_OPENSSL_HPP
diff --git a/src/security/safe-bag.cpp b/src/security/safe-bag.cpp
index 448847a..8315acf 100644
--- a/src/security/safe-bag.cpp
+++ b/src/security/safe-bag.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -20,7 +20,9 @@
  *
  * @author Zhiyi Zhang <dreamerbarrychang@gmail.com>
  */
+
 #include "safe-bag.hpp"
+#include "encoding/encoding-buffer.hpp"
 #include "encoding/tlv-security.hpp"
 #include "util/concepts.hpp"
 
@@ -74,11 +76,7 @@
   return totalLength;
 }
 
-template size_t
-SafeBag::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-SafeBag::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(SafeBag);
 
 const Block&
 SafeBag::wireEncode() const
diff --git a/src/security/safe-bag.hpp b/src/security/safe-bag.hpp
index 12555c9..13a2410 100644
--- a/src/security/safe-bag.hpp
+++ b/src/security/safe-bag.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -25,9 +25,8 @@
 
 #include "../common.hpp"
 #include "../data.hpp"
+#include "../encoding/block.hpp"
 #include "../encoding/buffer.hpp"
-#include "../encoding/encoder.hpp"
-#include "../encoding/encoding-buffer.hpp"
 #include "security-common.hpp"
 
 namespace ndn {
@@ -115,6 +114,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(SafeBag);
+
 } // namespace security
 } // namespace ndn
 
diff --git a/src/security/v1/sec-tpm-osx.cpp b/src/security/v1/sec-tpm-osx.cpp
index f43faa9..a54bf6e 100644
--- a/src/security/v1/sec-tpm-osx.cpp
+++ b/src/security/v1/sec-tpm-osx.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -149,7 +149,7 @@
       CFRelease(m_typeRef);
       m_typeRef = nullptr;
     }
-  };
+  }
 
   bool
   operator==(std::nullptr_t)
diff --git a/src/security/v2/additional-description.cpp b/src/security/v2/additional-description.cpp
index 6fdfd53..63b5ee6 100644
--- a/src/security/v2/additional-description.cpp
+++ b/src/security/v2/additional-description.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -109,11 +109,7 @@
   return totalLength;
 }
 
-template size_t
-AdditionalDescription::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-AdditionalDescription::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdditionalDescription);
 
 const Block&
 AdditionalDescription::wireEncode() const
diff --git a/src/security/v2/additional-description.hpp b/src/security/v2/additional-description.hpp
index d5142ae..ad9df37 100644
--- a/src/security/v2/additional-description.hpp
+++ b/src/security/v2/additional-description.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -52,7 +52,6 @@
   typedef std::map<std::string, std::string>::const_iterator const_iterator;
 
 public:
-
   /**
    * @brief Create an empty AdditionalDescription
    */
@@ -109,7 +108,6 @@
   wireDecode(const Block& wire);
 
 public: // EqualityComparable concept
-
   bool
   operator==(const AdditionalDescription& other) const;
 
@@ -117,12 +115,13 @@
   operator!=(const AdditionalDescription& other) const;
 
 private:
-
   std::map<std::string, std::string> m_info;
 
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdditionalDescription);
+
 std::ostream&
 operator<<(std::ostream& os, const AdditionalDescription& period);
 
diff --git a/src/security/validity-period.cpp b/src/security/validity-period.cpp
index 14ba0f2..c30497b 100644
--- a/src/security/validity-period.cpp
+++ b/src/security/validity-period.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -72,11 +72,7 @@
   return totalLength;
 }
 
-template size_t
-ValidityPeriod::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-ValidityPeriod::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ValidityPeriod);
 
 const Block&
 ValidityPeriod::wireEncode() const
diff --git a/src/security/validity-period.hpp b/src/security/validity-period.hpp
index d09657f..e87c6ec 100644
--- a/src/security/validity-period.hpp
+++ b/src/security/validity-period.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -125,6 +125,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ValidityPeriod);
+
 std::ostream&
 operator<<(std::ostream& os, const ValidityPeriod& period);
 
diff --git a/src/selectors.cpp b/src/selectors.cpp
index a207775..80c891f 100644
--- a/src/selectors.cpp
+++ b/src/selectors.cpp
@@ -109,11 +109,7 @@
   return totalLength;
 }
 
-template size_t
-Selectors::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-Selectors::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Selectors);
 
 const Block&
 Selectors::wireEncode() const
diff --git a/src/selectors.hpp b/src/selectors.hpp
index 960947f..5a80185 100644
--- a/src/selectors.hpp
+++ b/src/selectors.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -156,6 +156,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Selectors);
+
 } // namespace ndn
 
 #endif // NDN_SELECTORS_HPP
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index 1fc68f9..36964ac 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -82,11 +82,7 @@
   return totalLength;
 }
 
-template size_t
-SignatureInfo::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& encoder) const;
-
-template size_t
-SignatureInfo::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& encoder) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(SignatureInfo);
 
 const Block&
 SignatureInfo::wireEncode() const
diff --git a/src/signature-info.hpp b/src/signature-info.hpp
index 7ac8404..af6908d 100644
--- a/src/signature-info.hpp
+++ b/src/signature-info.hpp
@@ -162,6 +162,8 @@
   operator<<(std::ostream& os, const SignatureInfo& info);
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(SignatureInfo);
+
 bool
 operator==(const SignatureInfo& lhs, const SignatureInfo& rhs);
 
diff --git a/src/util/cf-releaser-osx.hpp b/src/util/cf-releaser-osx.hpp
index 61afeba..6c73ae8 100644
--- a/src/util/cf-releaser-osx.hpp
+++ b/src/util/cf-releaser-osx.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -138,7 +138,7 @@
       CFRelease(m_typeRef);
       m_typeRef = nullptr;
     }
-  };
+  }
 
 private:
   T m_typeRef;
diff --git a/src/util/logging.cpp b/src/util/logging.cpp
index 9961598..06948c1 100644
--- a/src/util/logging.cpp
+++ b/src/util/logging.cpp
@@ -30,6 +30,11 @@
 #include <iostream>
 #include <sstream>
 
+// suppress warning caused by <boost/log/sinks/text_ostream_backend.hpp>
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wundefined-func-template"
+#endif
+
 namespace ndn {
 namespace util {
 
diff --git a/src/util/regex/regex-pattern-list-matcher.hpp b/src/util/regex/regex-pattern-list-matcher.hpp
index fb0743b..ccac4b8 100644
--- a/src/util/regex/regex-pattern-list-matcher.hpp
+++ b/src/util/regex/regex-pattern-list-matcher.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -37,14 +37,9 @@
 public:
   RegexPatternListMatcher(const std::string& expr, shared_ptr<RegexBackrefManager> backrefManager);
 
-  virtual
-  ~RegexPatternListMatcher()
-  {
-  };
-
 protected:
-  virtual void
-  compile();
+  void
+  compile() override;
 
 private:
   bool
@@ -55,9 +50,6 @@
 
   int
   extractRepetition(size_t index);
-
-private:
-
 };
 
 } // namespace ndn
@@ -193,7 +185,6 @@
   }
 }
 
-
 } // namespace ndn
 
 #endif // NDN_UTIL_REGEX_REGEX_PATTERN_LIST_MATCHER_HPP
diff --git a/src/util/time-unit-test-clock.hpp b/src/util/time-unit-test-clock.hpp
index f099b84..7d67507 100644
--- a/src/util/time-unit-test-clock.hpp
+++ b/src/util/time-unit-test-clock.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -102,6 +102,9 @@
   nanoseconds m_currentTime;
 };
 
+extern template class UnitTestClock<system_clock>;
+extern template class UnitTestClock<steady_clock>;
+
 typedef UnitTestClock<system_clock> UnitTestSystemClock;
 typedef UnitTestClock<steady_clock> UnitTestSteadyClock;