Skip to content

Commit f8a2f4d

Browse files
Check Windows SDK version to use '/permissive-' flag only when supported
1 parent 8ffa35e commit f8a2f4d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

SConstruct

+7-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,13 @@ if selected_platform in platform_list:
330330
else:
331331
# MSVC doesn't have clear C standard support, /std only covers C++.
332332
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
333-
env.Prepend(CCFLAGS=['/std:c++17', '/permissive-'])
333+
sdk_version = os.getenv("WindowsSDKVersion")
334+
if (not sdk_version) or (methods.compare_version(sdk_version, "10.0.16299.0") >= 0):
335+
env.Prepend(CCFLAGS=['/std:c++17', '/permissive-'])
336+
else:
337+
print("The current Windows SDK version doesn't support '/permissive-' flag, "
338+
"it will be disabled.")
339+
env.Prepend(CCFLAGS=['/std:c++17'])
334340

335341
# Enforce our minimal compiler version requirements
336342
cc_version = methods.get_compiler_version(env) or [-1, -1]

methods.py

+11
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,17 @@ def get_compiler_version(env):
573573
else:
574574
return None
575575

576+
def compare_version(ver1, ver2):
577+
"""
578+
Takes two strings that represent version numbers of any size, separated with dots.
579+
Returns 1 if ver1 > ver2, -1 if ver1 < ver2, and 0 if ver1 == ver2.
580+
"""
581+
def normalize(v):
582+
return [int(re.sub(r'[^0-9]', '', x)) for x in re.sub(r'(\.0+)*$','', v).split(".")]
583+
def cmp(a, b):
584+
return (a > b) - (a < b)
585+
return cmp(normalize(ver1), normalize(ver2))
586+
576587
def using_gcc(env):
577588
return 'gcc' in os.path.basename(env["CC"])
578589

0 commit comments

Comments
 (0)