我正在尝试在 Visual Studio Code 如何使用 C/Cpp 扩展并将包含路径添加到配置 中编译 C++ 文件,但出现此错误:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.
cannot open source file "iostream"
我已经看到了 这个问题,并且任何解决方案都对我有用。我还按照 Visual Studio 代码教程的步骤录制 了一个视频。这是我的代码:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
}
这是我的 C/C++ 设置:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\x86_64-w64-mingw32\\include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
原文由 Andres Felipe Medina Ealo 发布,翻译遵循 CC BY-SA 4.0 许可协议
打开命令面板(ctrl + shift + P)然后搜索编辑配置,选择C/C++编辑配置(UI)。然后向下滚动,您将看到包含路径,通过在文件管理器中找到它来复制包含路径的位置,默认位置为 C:\Program Files(x86)\mingw-w64\……\ mingw32\包括。将智能感知设置为默认值。现在您已准备好享受您的编码之旅。