![如何设置 vscode C++ intellisense 以使用 gcc 编译器?](https://linux22.com/image/1691475/%E5%A6%82%E4%BD%95%E8%AE%BE%E7%BD%AE%20vscode%20C%2B%2B%20intellisense%20%E4%BB%A5%E4%BD%BF%E7%94%A8%20gcc%20%E7%BC%96%E8%AF%91%E5%99%A8%EF%BC%9F.png)
我在 vscode 中使用带有 Microsoft C/C++ 扩展的 C++。我使用 msys2 中提供的 g++ 编译器:
gcc --version
gcc.exe (Rev6, Built by MSYS2 project) 13.1.0
当我在编辑器中编写此代码时,它会显示错误波浪线:
*std::ranges::find(myvec, foo1) = foo2;
~~~
no instance of overloaded function "std::ranges::__find_fn::operator()" matches the argument list C/C++(304)
mycode.cpp(122, 3): argument types are: (std::vector<const Foo *, std::allocator<const Foo *>>, const Foo *)
mycode.cpp(122, 3): object type is: const std::ranges::__find_fn
但是,当我用编译此文件时-std=c++23
,它可以正确编译,甚至没有任何警告。
我的 C/C++ 配置如下:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"compilerArgs": [
"-std=c++23"
],
"intelliSenseMode": "linux-gcc-x64",
"cStandard": "c23",
"cppStandard": "c++23"
}
],
"version": 4
}
我该如何解决这些错误?