【发布时间】:2021-09-05 17:17:30
【问题描述】:
我不知道为什么我在#include <iostream> 上有红色下划线。我在 IDE 中使用 VSCode,并且已经安装了 C/C++。我的代码很基础,但我不知道为什么它仍然有红色下划线。
我的代码:
#include <iostream> //This line got red underline.
using namespace std;
int main() {
cout << "Hello";
retern 0;
}
当它运行时。
[运行] cd "c:\Users\hola\Desktop" && g++ testplusplus.cpp -o testplusplus && "c:\Users\hola\Desktop"testplusplus 'g++' 未被识别为内部或外部命令, 可运行的程序或批处理文件。
[Done] 在 0.05 秒内以 code=1 退出
【问题讨论】:
-
您有两个不相关的错误。第二个错误是由
g++不在PATH 中引起的。第一个是误报,它只是一个 VSC 问题,不会阻止您运行该程序。我认为如果您将错误悬停,它会解释如何修复它。 -
你安装
g++了吗? -
你告诉 VSC 这是一个 C++ 程序吗?
-
g++是 C++ 编译器。您需要安装一个编译器来编译您的 c++ 程序 -
提供
g++命令的编译器称为MinGW,或GCC。有许多不同质量的分布,here's a decent installation guide。