首页 > 解决方案 > Visual Studio Code 中的 C++ IntelliSense 无法识别 C++ STL

问题描述

我在我的 Linux 笔记本电脑上使用 Visual Studio Code。我刚刚写了一个像这样的简单程序main.cpp

#include<iostream>

int main()
{

}

昨天一切正常。今天我打开一个新文件,它说它不识别任何 STL 库。这是我将鼠标悬停在它上面时得到的:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/home/john/Documents/main.cpp).C/C++(1696)
cannot open source file "iostream"C/C++(1696)

我运行一些命令来检查我的编译器和设置。这些是我的智能设置:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "configurationProvider": "go2sh.cmake-integration"
        }
    ],
    "version": 4
}

这是关于我的g++编译器和我的clang编译器的一些信息:

g++

john@john-GL63-8RC:~$ whereis g++
g++: /usr/bin/g++ /usr/share/man/man1/g++.1.gz
john@john-GL63-8RC:~$ g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

clang

john@john-GL63-8RC:~$ whereis clang
clang: /usr/bin/clang /usr/lib/clang /usr/include/clang /usr/share/man/man1/clang.1.gz
john@john-GL63-8RC:~$ clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

另外我认为它们很旧,但我所做的只是通过 apt-get 安装如何更新它们?我该如何修复它?我没有改变任何东西,它只是开始自己发疯

标签: c++gccvisual-studio-codeclangintellisense

解决方案


推荐阅读