From df4d769f99743f9369b394746e0a3a8b35693e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 2 Jan 2025 19:39:27 +0100 Subject: [PATCH] SCons: Set explicit standards to C++98 and C11 For GCC the 2.1 branch only supports up to GCC 5, which defaulted to those versions. Trying to build with modern Clang (thus bypassing the GCC version check) fails because the code is not C++17 compliant. --- SConstruct | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index f336680a79b..e3c7d2498b1 100644 --- a/SConstruct +++ b/SConstruct @@ -295,10 +295,23 @@ if selected_platform in platform_list: # must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11) detect.configure(env) + # Set our C and C++ standard requirements. + # Prepending to make it possible to override. + is_msvc = os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp") + if (not is_msvc): + # Specifying GNU extensions support explicitly, which are supported by both GCC and Clang. + # We don't support C++17 so stick to earlier standards. + # When 2.1 was actively worked on, we were using GCC 5 which defaults to C++98, so use that. + env.Prepend(CFLAGS=["-std=gnu11"]) + env.Prepend(CXXFLAGS=["-std=gnu++98"]) + else: + # MSVC doesn't support setting C++ to pre-C++14 standards, so do nothing and hope it works. + pass + if (env["warnings"] == 'yes'): print("WARNING: warnings=yes is deprecated; assuming warnings=all") - if (os.name == "nt" and os.getenv("VCINSTALLDIR") and (platform_arg == "windows" or platform_arg == "uwp")): # MSVC, needs to stand out of course + if (is_msvc): # MSVC disable_nonessential_warnings = ['/wd4267', '/wd4244', '/wd4305', '/wd4800'] # Truncations, narrowing conversions... if (env["warnings"] == 'extra'): env.Append(CCFLAGS=['/Wall']) # Implies /W4