Properly disable exceptions in MSVC.

This commit is contained in:
Patrick 2025-03-07 11:00:17 +01:00
parent 726d206f9a
commit b034e87aaf

View File

@ -926,19 +926,20 @@ elif env['COMPILER_FAMILY'] == 'cl':
'c++23': 'c++latest', 'c++23': 'c++latest',
'c++26': 'c++latest' 'c++26': 'c++latest'
}.get(env['CXX_STANDARD'], 'c++14') # default to C++14 for older versions }.get(env['CXX_STANDARD'], 'c++14') # default to C++14 for older versions
if env['CXX_NO_EXCEPTIONS']:
exception_option = ''
else:
exception_option = '/EHsc'
# C4201: nonstandard extension used : nameless struct/union - I use it and want to continue using it # C4201: nonstandard extension used : nameless struct/union - I use it and want to continue using it
# C4127: conditional expression is constant - some libs (CRC, format) don't compile with this enabled # TODO: fix? # C4127: conditional expression is constant - some libs (CRC, format) don't compile with this enabled # TODO: fix?
# C4702: unreachable code, issued after MIJIN_FATAL macro # C4702: unreachable code, issued after MIJIN_FATAL macro
# C4251: missing dll-interface of some std types, yaml-cpp doesn't compile with this enabled # C4251: missing dll-interface of some std types, yaml-cpp doesn't compile with this enabled
# C4275: same as above # C4275: same as above
env.Append(CCFLAGS = ['/W4', '/WX', '/wd4201', '/wd4127', '/wd4702', '/wd4251', '/wd4275', '/bigobj', '/vmg', env.Append(CCFLAGS = ['/W4', '/WX', '/wd4201', '/wd4127', '/wd4702', '/wd4251', '/wd4275', '/bigobj', '/vmg',
f'/std:{cxx_version_name}', '/permissive-', exception_option, '/FS', '/Zc:char8_t', '/utf-8']) f'/std:{cxx_version_name}', '/permissive-', '/FS', '/Zc:char8_t', '/utf-8'])
env.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS']) # I'd like to not use MSVC specific versions of functions because they are "safer" ... env.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS']) # I'd like to not use MSVC specific versions of functions because they are "safer" ...
env.Append(DEPS_CXXFLAGS = [exception_option, '/Zc:char8_t', '/utf-8', '/vmg']) env.Append(DEPS_CXXFLAGS = ['/Zc:char8_t', '/utf-8', '/vmg'])
if env['CXX_NO_EXCEPTIONS']:
env.Append(CPPDEFINES = ['_HAS_EXCEPTIONS=0'])
else:
env.Append(CXXFLAGS = ['/EHsc'])
env.Append(DEPS_CXXFLAGS = ['/EHsc'])
if env['SHOW_INCLUDES']: if env['SHOW_INCLUDES']:
env.Append(CCFLAGS = ['/showIncludes']) env.Append(CCFLAGS = ['/showIncludes'])
if build_type == 'debug': if build_type == 'debug':