【发布时间】:2021-09-20 04:55:17
【问题描述】:
我正在尝试在 Visual Studio Code How to use C/Cpp extension and add includepath to configurations 中编译 C++ 文件,但出现以下错误:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.
cannot open source file "iostream"
我已经看到 this question 并且任何解决方案都对我有用。我还按照 Visual Studio 代码教程的步骤录制了a video。这是我的代码:
#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
}
【问题讨论】:
-
请分享您的代码。没有它就很难提供帮助。
-
这是一个简单的Hello World,和微软页面中的一样。
-
好的,知道了!那么这段代码所在的文件的名称是什么?编译时使用的确切命令行是什么?编辑:似乎是 VS Code 中的一个错误:github.com/microsoft/vscode-cpptools/issues/3852
-
文件名是helloword.cpp,我编译的时候没有使用命令行,我使用“终端>运行构建任务”。 Visual Studio 中的选项
-
必须有办法让 VS Code 显示它使用的命令。
标签: c++ visual-studio-code mingw