I'm using CMake generator and MSVC compiler with VSCode editor while programming C++, but something troubled me when I try to switch language support extension to clangd.
It works correctly set CXX_STANDARD to C++20, but when I tried upgrading to C++23, CMake generates "-std:c++latest" instead of "-std:c++23" to compile_commands.json. In my source files, both macro __cplusplus and _MSVC_LANG equals to 201402L, not 2023xxL. (But I can normally compile C++23 features)
Do CMake and clangd support c++23? I found that there was -std:c++23 support for Clang in its official documentation, But it either not works when I manually replaced "-std:c++latest" to "-std:C++23".
My clangd and CMake are in newest versions.
My configurations:
How It works in C++20 standard:
How it doesn't work in C++23 standard: (clangd says it is c++14!)
I tried to manually replaced "-std:c++latest" to "-std:C++23", then upgraded CMake and clangd version newest. But problen still exsits.
This is a Clangd bug (or this one).
The workaround is to add following to
.clangd(config file in your project dir):