【问题标题】:Configuring VS code for c++ programming and development为 C++ 编程和开发配置 VS 代码
【发布时间】:2020-05-11 10:03:27
【问题描述】:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\LENOVO\Desktop\projects\helloworld\helloworld.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;
 }

这是我要运行的 sn-p。

【问题讨论】:

  • 您能否使用您正在使用的确切 #include 代码更新您的问题?我在那里看到双引号,这可能是你的问题。

标签: c++ visual-c++ c++14 configure


【解决方案1】:

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

【讨论】:

  • 虽然链接可能会回答问题,但最好将相关部分作为文本包含在答案本身中。否则,如果链接死了,答案将变得毫无用处。见stackoverflow.com/help/deleted-answers
【解决方案2】:

尝试在中配置包含路径数组设置 .vscode\c_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. Configurations.

它还可以提供帮助:

#include "stdafx.h"

【讨论】:

  • 虽然链接可能会回答问题,但最好将相关部分作为文本包含在答案本身中。否则,如果链接死了,答案将变得毫无用处。见stackoverflow.com/help/deleted-answers
猜你喜欢
  • 2018-10-26
  • 1970-01-01
  • 2021-05-23
  • 2022-06-30
  • 1970-01-01
  • 2017-10-24
  • 2022-01-15
  • 1970-01-01
  • 2022-11-24
相关资源
最近更新 更多