build: update default CXXFLAGS.
* Add -std=c++03 and -pedantic, 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.
* Initial support for building with -std=c++11 (experimental).
* Prefer -Og optimization level in debug builds if supported by the
compiler.
Change-Id: I744a25c8b52842dc3ea3a733d6ab2fa66171e6f8
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 299493a..9f7843e 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -12,14 +12,24 @@
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:
@@ -27,11 +37,11 @@
% " ".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):
@@ -45,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