可视化配置 VS 代码以进行 C++ 编程和开发

visual Configuring VS code for c++ programming and development

本文关键字:C++ 编程 开发 配置 VS 代码 可视化      更新时间:2023-10-16
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:UsersLENOVODesktopprojectshelloworldhelloworld.cpp).C/C++(1696)
cannot open source file "iostream"C/C++(1696)

每当我尝试包含或任何其他文件时,都会显示上述内容。我已经安装了MinGw并且已经设置了路径环境变量。我还在 Vs 代码中安装了 c/c++ Microsoft 扩展。我仍然不明白这里发生了什么。有人可以帮忙吗

#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string& word : msg)
{
cout << word << " ";
}
cout << endl;
}

这是我尝试运行的代码段。

请参阅此文档。 设置编译器路径我认为它会起作用

尝试在 中配置包含路径数组设置.vscodec_cpp_properties.json.

{
"configurations": [
{
"name": "Win32",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x86"
}
],
"version": 4
}

来源:C/C++ for Visual Studio Code。配置。

它还可以帮助:

#include "stdafx.h"