VScode找不到C++万能头文件<bits/stdc++.h>解决办法

一、万能头文件介绍

万能头文件<bits/stdc++> 中包含了 C++中大部分头文件,在大部分做题平台、比赛当中都支持万能头文件的包含,这样以来可以减少编写头文件的工作量,节约做题时间,让选手更加专注于算法本身。但是在程序编写时不推荐使用,万能头文件不是C++标准的一部分,减少了代码的可移植性。

二、出现问题

  • 在使用VScode时发现万能头文件<bits/stdc++>的包含语句下出现红色波浪线。

三、解决思路

  • 出现问题的原因:
    VScode不能在头文件的搜素路径中找到头文件。
  • 解决方案
    由于头文件中的语句只是一些文件包含语句,因此可以创建一个头文件,将其移动到系统的搜素路径下。

四、操作步骤

  • 首先输入能搜素到的头文件 < iostream >

    #include<iostream>
    

  • 通过此头文件找到头文件目录

    • 选中 iostream ,右键转到定义

    • 在 左侧右键点击 iostream 文件,在文件夹中显示

  • 创建一个名为 stdc++.h 的文件,将以下代码复制到文件中保存

    // C++ includes used for precompiling -*- C++ -*-
    // Copyright (C) 2003-2014 Free Software Foundation, Inc. This file is part of the GNU ISO C++ Library.  This library is free// software; you can redistribute it and/or modify it under the// terms of the GNU General Public License as published by the// Free Software Foundation; either version 3, or (at your option)// any later version.
    // This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.
    // Under Section 7 of GPL version 3, you are granted additional// permissions described in the GCC Runtime Library Exception, version// 3.1, as published by the Free Software Foundation.
    // You should have received a copy of the GNU General Public License and// a copy of the GCC Runtime Library Exception along with this program;// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see// <http://www.gnu.org/licenses/>.
    /** @file stdc++.h *  This is an implementation file for a precompiled header. */
    // 17.4.1.2 Headers
    // C
    #ifndef _GLIBCXX_NO_ASSERT
    #include <cassert>
    #endif
    #include <cctype>
    #include <cerrno>
    #include <cfloat>
    #include <ciso646>
    #include <climits>
    #include <clocale>
    #include <cmath>
    #include <csetjmp>
    #include <csignal>
    #include <cstdarg>
    #include <cstddef>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>#if __cplusplus >= 201103L
    #include <ccomplex>
    #include <cfenv>
    #include <cinttypes>
    #include <cstdalign>
    #include <cstdbool>
    #include <cstdint>
    #include <ctgmath>
    #include <cwchar>
    #include <cwctype>
    #endif// C++
    #include <algorithm>
    #include <bitset>
    #include <complex>
    #include <deque>
    #include <exception>
    #include <fstream>
    #include <functional>
    #include <iomanip>
    #include <ios>
    #include <iosfwd>
    #include <iostream>
    #include <istream>
    #include <iterator>
    #include <limits>
    #include <list>
    #include <locale>
    #include <map>
    #include <memory>
    #include <new>
    #include <numeric>
    #include <ostream>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stack>
    #include <stdexcept>
    #include <streambuf>
    #include <string>
    #include <typeinfo>
    #include <utility>
    #include <valarray>
    #include <vector>#if __cplusplus >= 201103L
    #include <array>
    #include <atomic>
    #include <chrono>
    #include <condition_variable>
    #include <forward_list>
    #include <future>
    #include <initializer_list>
    #include <mutex>
    #include <random>
    #include <ratio>
    #include <regex>
    #include <scoped_allocator>
    #include <system_error>
    #include <thread>
    #include <tuple>
    #include <typeindex>
    #include <type_traits>
    #include <unordered_map>
    #include <unordered_set>
    #endif

  • 将保存好的头文件放入之前打开的include目录下(需要管理员权限)

  • 这时候返回vscode,发现红色下划线消失了

四、结果检测

用Hello word测试以下

#include <bits/stdc++.h>
using namespace std;
int main()
{cout << "Hello world\n";return 0;
}


万能头文件可以使用了!

VScode找不到C++万能头文件<bits/stdc++.h>解决办法相关推荐

  1. C++万能头文件(bits/stdc++.h)

    先说一句 C++万能头文件,并不是所有场合都能用,比如说POJ. 我曾在POJ提交过程序,编译错误.就是因为用了万能头文件. 意思就是,不认识<bits/stdc++.h>. 因为,万能头 ...

  2. VS C++万能头文件bits/stdc++.h的配置

    万能头文件:#include<bits/stdc++.h> 路径:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\To ...

  3. 【环境配置】macOS的Xcode中使用C++万能头文件bits/stdc++.h

    启动终端 cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c ...

  4. 【C++】头文件 bits/stdc++.h 是啥?

    原文地址: [C++]头文件 bits/stdc++.h 是啥? 欢迎访问我的博客:http://blog.duhbb.com/ 嘿嘿, 以后写 leetcode 的话, 本地直接就引用这个文件, 还 ...

  5. 浅说万能头<bits/stdc++.h>

    #include<bits/stdc++.h>包含了C和C++的绝大多数头文件,像iostream.cmath.algorithm.iomanip.string之类的,这意味着我们不再需要 ...

  6. C++预编译头文件 bits/stdc++.h

    有时候会看到别人包含这样的头文件: #include "bits/stdc++.h" 这个头文件中有很多预先包含的头文件,内容如下: // C++ includes used fo ...

  7. 高级c++头文件bits/stdc++.h

    用这种方法声明头文件只需两行代码 #include<bits/stdc++.h> using namespace std; 这个头文件包含以下等等C++中包含的所有头文件: #includ ...

  8. std.h对应linux头文件,bits/stdc++.h头文件介绍(包含源代码)

    注:转自http://blog.csdn.net/charles_dong2/article/details/56909347,同为本人写的,有部分修改. 之前在一个小OJ上刷题时发现有人是这么写的: ...

  9. Cfree之万能头函数bits\stdc++.h的添加和注意事项

    实现步骤 一.创建一个.txt文件,把下面的代码复制进去 // C++ includes used for precompiling -*- C++ -*-// Copyright (C) 2003- ...

最新文章

  1. 刚刚,百度宣布王海峰升任CTO
  2. python sys模块 输入输出 错误流
  3. 【markdown】图片的处理
  4. 3、Python字典集合
  5. 服务器linux启动,Linux 服务器环境启动
  6. vscode使用相关配置
  7. Npm 恶意包试图窃取 Discord 敏感信息和浏览器文件
  8. MT4的交易记录导入“复盘大师3”的解决办法
  9. 压缩包上传 压缩并解压缩Rar/Zip
  10. win7设置自动开机时间_win7本地连接ip设置方法
  11. Ubiquitous Religions(并查集)
  12. IDEA插件系列(94):Pomodoro-tm插件——番茄钟计时
  13. 《操作系统真象还原》从零开始自制操作系统 自写源码实现 (fs相关文件)
  14. 查看创建数据库的sql语句
  15. jib构建镜像(使用阿里云容器镜像服务拉取镜像)
  16. 叉乘点乘混合运算公式_小学数学所有公式和顺口溜都在这里了,假期让孩子背熟!...
  17. 小白安装cadence virtuoso
  18. 力扣 1833. 雪糕的最大数量
  19. 钢琴软件c语言源代码,使用C语言编写钢琴小程序
  20. 真实孔径雷达——东方至远

热门文章

  1. 人脸方向学习(十二):Face Detection-Tiny-DSOD解读
  2. ft2232驱动安装方法_win7系统无法安装打印机驱动程序的解决方法
  3. ERROR 1130 (HY000): Host ‘192.168.3.238‘ is not allowed to connect to this MySQL server
  4. rstudio 修改代码间距_如何在RStudio里修改R脚本的编码方式
  5. python多进程编程实例_[python] Python多进程编程技术实例分析
  6. docker容器的标准使用过程_docker容器的使用
  7. List增删元素后size大小发生变化带来的影响、Stream流操作、Lambda表达式
  8. java 创建本地文件、写入文本内容、调用IE浏览器打开
  9. 交换机千兆和百兆对网速影响_电信宽带升级为200M,为什么网速没有提升多少?...
  10. python爬虫预测_从爬虫到机器学习预测,我是如何一步一步做到的?