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/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 265259e..9f7843e 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -12,27 +12,36 @@
 
 def configure(conf):
     areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
+    defaultFlags = []
+
+    if conf.options.use_cxx11:
+        defaultFlags += ['-std=c++0x', '-std=c++11']
+    else:
+        defaultFlags += ['-std=c++03']
+
+    defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long']
+
     if conf.options.debug:
         conf.define('_DEBUG', 1)
-        defaultFlags = ['-O0', '-g3',
-                        '-Werror',
-                        '-Wall',
-                        '-fcolor-diagnostics', # only clang supports
+        defaultFlags += ['-O0',
+                         '-Og', # gcc >= 4.8
+                         '-g3',
+                         '-fcolor-diagnostics', # clang
+                         '-fdiagnostics-color', # gcc >= 4.9
+                         '-Werror'
                         ]
-
         if areCustomCxxflagsPresent:
             missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
             if len(missingFlags) > 0:
                 Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
-                           % " ".join(conf.env.CXXFLAGS))
+                          % " ".join(conf.env.CXXFLAGS))
                 Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
         else:
-            conf.add_supported_cxxflags(cxxflags = defaultFlags)
+            conf.add_supported_cxxflags(defaultFlags)
     else:
-        defaultFlags = ['-O2', '-g', '-Wall',
-                        ]
+        defaultFlags += ['-O2', '-g']
         if not areCustomCxxflagsPresent:
-            conf.add_supported_cxxflags(cxxflags = defaultFlags)
+            conf.add_supported_cxxflags(defaultFlags)
 
 @Configure.conf
 def add_supported_cxxflags(self, cxxflags):
@@ -46,5 +55,5 @@
         if self.check_cxx(cxxflags=[flag], mandatory=False):
             supportedFlags += [flag]
 
-    self.end_msg(' '.join (supportedFlags))
+    self.end_msg(' '.join(supportedFlags))
     self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS