From e29ae4e08ccce7f120f8ee88dd238bd2b4facbf4 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 15 Oct 2023 15:12:23 +0200 Subject: Issue #2281 - Default to C++17 when building. Configure the toolchain to default to C++17 language standard with optional gnu extensions (if on GCC) --- build/moz.configure/toolchain.configure | 19 +++++++++---------- build/moz.configure/warnings.configure | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index cc0540ea1c..40b87cf626 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -340,17 +340,16 @@ def check_compiler(compiler, language, target): if info.type in ('clang-cl', 'clang', 'gcc'): append_flag('-std=gnu99') - # Note: this is a strict version check because we used to always add - # -std=gnu++14. - cxx14_version = 201402 + cxx17_version = 201703 if info.language == 'C++': - if info.type in ('clang', 'gcc') and info.language_version != cxx14_version: - append_flag('-std=gnu++14') - # MSVC 2015 headers include C++14 features, but don't guard them - # with appropriate checks. - if info.type == 'clang-cl' and info.language_version != cxx14_version: - append_flag('-std=c++14') - # MSVC from 2015 on defaults to C++14. + if info.language_version != cxx17_version: + # Compiler doesn't default to C++17, so add the appropriate flag. + if info.type in ('clang', 'gcc'): + # We're on Clang or GCC, enable C++17 and add GNU extensions. + append_flag('-std=gnu++17') + else: + # We're on MSVC; enable C++17 language mode. + append_flag('-std:c++17') # We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to # cl.exe. diff --git a/build/moz.configure/warnings.configure b/build/moz.configure/warnings.configure index 2edf1748ad..0704f94a09 100644 --- a/build/moz.configure/warnings.configure +++ b/build/moz.configure/warnings.configure @@ -52,7 +52,7 @@ check_and_add_gcc_warning('-Wclass-varargs') check_and_add_gcc_warning('-Wloop-analysis') # catches C++ version forward-compat issues -check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler) +# check_and_add_gcc_warning('-Wc++2a-compat', cxx_compiler) # catches unintentional switch case fallthroughs check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler) -- cgit v1.2.3