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/.waf-tools/boost.py b/.waf-tools/boost.py
index 6d79788..2b4b05a 100644
--- a/.waf-tools/boost.py
+++ b/.waf-tools/boost.py
@@ -61,6 +61,14 @@
 #include <boost/version.hpp>
 int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
 '''
+BOOST_SYSTEM_CODE = '''
+#include <boost/system/error_code.hpp>
+int main() { boost::system::error_code c; }
+'''
+BOOST_THREAD_CODE = '''
+#include <boost/thread.hpp>
+int main() { boost::thread t; }
+'''
 
 # toolsets from {boost_dir}/tools/build/v2/tools/common.jam
 PLATFORM = Utils.unversioned_sys_platform()
@@ -310,19 +318,13 @@
 	def try_link():
 		if 'system' in params['lib']:
 			self.check_cxx(
-			 fragment="\n".join([
-			  '#include <boost/system/error_code.hpp>',
-			  'int main() { boost::system::error_code c; }',
-			 ]),
+			 fragment=BOOST_SYSTEM_CODE,
 			 use=var,
 			 execute=False,
 			)
 		if 'thread' in params['lib']:
 			self.check_cxx(
-			 fragment="\n".join([
-			  '#include <boost/thread.hpp>',
-			  'int main() { boost::thread t; }',
-			 ]),
+			 fragment=BOOST_THREAD_CODE,
 			 use=var,
 			 execute=False,
 			)