最近,经过很长一段时间,我在大学里重新安装了C++。在安装了C++扩展包之后,我用"HelloWorld“代码进行了测试,发现名称空间"std”的所有成员都犯了错误,如下所示。我仍然可以像往常一样编译和运行它,但是显示的错误让我非常不高兴。
我试着找出一些解决办法。所有这些问题都与缺少的#include<iostream>、using namespace std、更改intelliSenseMode、C_Cpp.errorSquiggles或其他相关,但没有一个是正确的答案。
为什么会发生这种事?
这是我的c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"D:/Code/Path/mingw64/x86_64-w64-mingw32/include",
"D:/Code/Path/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/include",
"D:/Code/Path/mingw64/include/c++/12.2.0/x86_64-w64-mingw32"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4}
settings.json:
{
"cSpell.words": [
"heapify",
"HUST",
"Inorder"
],
"C_Cpp.errorSquiggles": "EnabledIfIncludesResolve"}
你好-world.cpp:
#include <iostream>
int main()
{
std::cout << "Hello world" << std::endl;
}发布于 2022-10-12 09:29:06
从Why is visual studio code telling me that cout is not a member of std namespace?答案来看,它应该是VS代码中的一个bug。
您应该进入VS代码中的File -> Preferences -> Settings并进行更改
"C_Cpp.intelliSenseEngine": "Default"到"C_Cpp.intelliSenseEngine": "Tag Parser"。也许这个答案有帮助!
https://stackoverflow.com/questions/74039252
复制相似问题