aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-11-13 19:20:10 -0800
committerGitHub <noreply@github.com>2020-11-13 19:20:10 -0800
commit8dcc7d3ef3cb95029c41a0d4accef86415f29cb8 (patch)
treee9711673000ffbb7f339cff7fd53c897ade457e3
parent91876b40316962620c1705ae14075ab46f8dd644 (diff)
parent2748c9fb3d6e3195f5cb8adb31f0565f8b49436d (diff)
downloadmeson-8dcc7d3ef3cb95029c41a0d4accef86415f29cb8.zip
meson-8dcc7d3ef3cb95029c41a0d4accef86415f29cb8.tar.gz
meson-8dcc7d3ef3cb95029c41a0d4accef86415f29cb8.tar.bz2
Merge pull request #7967 from jpark37/msvc-c17
msvc: enable /std:c17 flag
-rw-r--r--mesonbuild/compilers/c.py27
-rw-r--r--test cases/unit/59 introspect buildoptions/meson.build2
2 files changed, 20 insertions, 9 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 4900876..985f6f3 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -410,6 +410,9 @@ class VisualStudioLikeCCompilerMixin(CompilerMixinBase):
class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompiler):
+ _C11_VERSION = '>=19.28'
+ _C17_VERSION = '>=19.28'
+
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo', target: str,
exe_wrapper: T.Optional['ExternalProgram'] = None,
@@ -422,25 +425,33 @@ class VisualStudioCCompiler(MSVCCompiler, VisualStudioLikeCCompilerMixin, CCompi
def get_options(self) -> 'OptionDictType':
opts = super().get_options()
- c_stds = ['none', 'c89', 'c99', 'c11',
+ c_stds = ['c89', 'c99']
# Need to have these to be compatible with projects
# that set c_std to e.g. gnu99.
# https://github.com/mesonbuild/meson/issues/7611
- 'gnu89', 'gnu90', 'gnu9x', 'gnu99', 'gnu1x', 'gnu11']
- opts['std'].choices = c_stds # type: ignore
+ g_stds = ['gnu89', 'gnu90', 'gnu9x', 'gnu99']
+ if version_compare(self.version, self._C11_VERSION):
+ c_stds += ['c11']
+ g_stds += ['gnu1x', 'gnu11']
+ if version_compare(self.version, self._C17_VERSION):
+ c_stds += ['c17', 'c18']
+ g_stds += ['gnu17', 'gnu18']
+ opts['std'].choices = ['none'] + c_stds + g_stds # type: ignore
return opts
def get_option_compile_args(self, options: 'OptionDictType') -> T.List[str]:
args = []
std = options['std']
if std.value.startswith('gnu'):
- mlog.log(
+ mlog.log_once(
'cl.exe does not actually support gnu standards, and meson '
'will instead demote to the nearest ISO C standard. This '
- 'may cause compilation to fail.', once=True)
- # As of MVSC 16.7, /std:c11 is the only valid C standard option.
- if std.value in {'c11', 'gnu11'}:
+ 'may cause compilation to fail.')
+ # As of MVSC 16.8, /std:c11 and /std:c17 are the only valid C standard options.
+ if std.value in {'c11', 'gnu1x', 'gnu11'}:
args.append('/std:c11')
+ elif std.value in {'c17', 'c18', 'gnu17', 'gnu18'}:
+ args.append('/std:c17')
return args
@@ -485,7 +496,7 @@ class IntelClCCompiler(IntelVisualStudioLikeCompiler, VisualStudioLikeCCompilerM
args = []
std = options['std']
if std.value == 'c89':
- mlog.log("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.", once=True)
+ mlog.log_once("ICL doesn't explicitly implement c89, setting the standard to 'none', which is close.")
elif std.value != 'none':
args.append('/Qstd:' + std.value)
return args
diff --git a/test cases/unit/59 introspect buildoptions/meson.build b/test cases/unit/59 introspect buildoptions/meson.build
index 16df028..9cfdc2c 100644
--- a/test cases/unit/59 introspect buildoptions/meson.build
+++ b/test cases/unit/59 introspect buildoptions/meson.build
@@ -1,4 +1,4 @@
-project('introspect buildargs', ['c'], default_options: ['c_std=c11', 'cpp_std=c++14', 'buildtype=release'])
+project('introspect buildargs', ['c'], default_options: ['c_std=c99', 'cpp_std=c++14', 'buildtype=release'])
subA = subproject('projectA')