summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-20 14:04:25 +0100
committerGitHub <noreply@github.com>2020-02-20 14:04:25 +0100
commitf5bb6d6a7c6d225b15a8022a8511e3918fd02048 (patch)
treee9bac54677a63168997608684adca3546223f7bd
parentbd61281a5f515065b05be008dd3d6b73a03f5a7c (diff)
parent342f127362108bfb0fb954c9150b5a937ecfef30 (diff)
Merge pull request #36380 from akien-mga/scons-std-c11-c++14
SCons: Explicitly define our C (C11) and C++ (C++14) standards
-rw-r--r--SConstruct21
1 files changed, 16 insertions, 5 deletions
diff --git a/SConstruct b/SConstruct
index fe6178d670..785686d428 100644
--- a/SConstruct
+++ b/SConstruct
@@ -292,6 +292,7 @@ if selected_platform in platform_list:
if env["extra_suffix"] != '':
env.extra_suffix += '.' + env["extra_suffix"]
+ # Environment flags
CCFLAGS = env.get('CCFLAGS', '')
env['CCFLAGS'] = ''
env.Append(CCFLAGS=str(CCFLAGS).split())
@@ -308,18 +309,28 @@ if selected_platform in platform_list:
env['LINKFLAGS'] = ''
env.Append(LINKFLAGS=str(LINKFLAGS).split())
+ # Set our C and C++ standard requirements.
+ # Prepending to make it possible to override
+ if not env.msvc:
+ # Specifying GNU extensions support explicitly, which are supported by
+ # both GCC and Clang. This mirrors GCC and Clang's current default
+ # compile flags if no -std is specified.
+ env.Prepend(CFLAGS=['-std=gnu11'])
+ env.Prepend(CXXFLAGS=['-std=gnu++14'])
+ else:
+ # MSVC doesn't have clear C standard support, /std only covers C++.
+ # We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
+ env.Prepend(CCFLAGS=['/std:c++14', '/permissive-'])
+
+ # Platform specific flags
flag_list = platform_flags[selected_platform]
for f in flag_list:
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
env[f[0]] = f[1]
- # must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
+ # Must happen after the flags definition, so that they can be used by platform detect
detect.configure(env)
- # Enable C++11 support
- if not env.msvc:
- env.Append(CXXFLAGS=['-std=c++11'])
-
# Configure compiler warnings
if env.msvc:
# Truncations, narrowing conversions, signed/unsigned comparisons...