build: add -std=c++03 (in non C++11 mode) and -pedantic to the default CXXFLAGS
And fix the resulting warnings. The long-long-int warning is explicitly
suppressed because it's not trivial to workaround in a platform-independent
and ISO-conformant way without using C++11.
This commit also includes fix for the advisory check for C++11-enabled
compiler in common.hpp (gcc < 4.7 does not correctly define __cpluplus
macro).
Finally, when custom CXXFLAGS are specified, --with-c++11 does not force
-std=c++11 or -std=c++0x flags, but just performs mandatory checks for
std::shared_ptr and std::function.
Change-Id: Icf44627edfddd34301bd27a05882b62fcbf54329
diff --git a/src/common.hpp b/src/common.hpp
index 457ac23..79f6c1c 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -45,11 +45,18 @@
#define DEPRECATED(func) func
#endif
-#if NDN_CPP_HAVE_CXX11
+#ifdef NDN_CPP_HAVE_CXX11
-#if (__cplusplus < 201103L)
-#error "NDN-CPP-DEV library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
-#endif
+#if defined(__GNUC__)
+# if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
+# error "NDN-CPP-DEV library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
+# endif // !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
+#endif // defined(__GNUC__)
+
+#if defined(__clang__) && __cplusplus < 201103L
+# error "NDN-CPP-DEV library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
+#endif // defined(__clang__) && (__cplusplus < 201103L)
+
#include <memory>
#include <functional>
@@ -60,6 +67,7 @@
namespace func_lib = std;
using std::shared_ptr;
+using std::weak_ptr;
using std::make_shared;
using std::enable_shared_from_this;
@@ -77,6 +85,7 @@
#else
#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/make_shared.hpp>
@@ -89,6 +98,7 @@
namespace func_lib = boost;
using boost::shared_ptr;
+using boost::weak_ptr;
using boost::make_shared;
using boost::enable_shared_from_this;
@@ -101,7 +111,7 @@
} // namespace ndn
-#endif
+#endif // NDN_CPP_HAVE_CXX11
namespace ndn {