mesonbuild/meson

Support for C++23 with clang-cl and Visual Studio

Fechada

#15.845 aberto em 27 de mai. de 2026

 (3 comentários) (0 reação) (0 responsável)Python (1.465 forks)batch import
OS:windowscompilersgood first issuehelp wanted

Métricas do repositório

Stars
 (4.978 estrelas)
Métricas de merge de PR
 (Mesclagem média 139d 13h) (51 fundiu PRs em 30d)

Description

Hi,

When using clang-cl and setting cpp_std = 'c++23' Meson complains that None of values ['c++23'] are supported by the CPP compiler. Possible values for option "cpp_std" are ['none', 'none', 'c++11', 'vc++11', 'c++14', 'vc++14', 'c++17', 'vc++17', 'c++20', 'vc++20', 'c++latest']".
The problem is that depending on the compiler version, c++latest is actually C++26, not C++23.

The only way to get C++23 with LLVM 19 is /clang:-std=c++23. LLVM 20 introduces support for /std:c++23preview (https://github.com/llvm/llvm-project/pull/112378) but there was an issue with modules (https://github.com/llvm/llvm-project/issues/173544) which was fixed in LLVM 22 (https://github.com/llvm/llvm-project/pull/173663).

CMake uses /clang:-std=c++23 (https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9818).
Conan will also use /clang:-std=c++23 in version 2.29 (https://github.com/conan-io/conan/pull/19965).
I see that Meson already uses the /clang:-std= trick for C standards (https://github.com/mesonbuild/meson/pull/7866).

A similar issue exists for Visual Studio, because starting with version 17.13 Preview 4 /std:c++23preview is the flag for C++23 while /std:c++latest may enable newer features (https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170#stdc23preview).

Checked with Meson from master (8fb36fb1fc976af39e94b8e7469f7bfc0f8e8678).

Guia do colaborador