C++无法打开源文件bits/stdc++.h的问题

 更新时间:2023年08月04日 10:12:48   作者:Lv.Twelve.  
这篇文章主要介绍了C++无法打开源文件bits/stdc++.h的问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

VS 是不支持 万能头的,需要我们自己去手动添加。

原理

首先我们得知道万能头是个啥东西。(其实是我不知道。。QAQ)<bits/stdc++.h> 其实就是一个头文件,里面包含了几乎所有的C++库里的头文件

因此一般只需要包含这一个头文件就能满足所有的需求

不过自然也会有着一些缺点。

优点

  • 简单便捷。能满足大多数场合,即一些对运行需求不大严格的场合。
  • 节省时间,不必考虑需要加入哪些头文件。这对参与竞赛的时候能起到一点帮助。

缺点

  • 包含所有的头文件,编译时速度自然就稍慢一些,增加编译时间。
  • 这不是C++的标准库,因而不是所有的编译系统都有,比如一些OJ就可能没有。
  • 不建议新手使用,新手还是要多用用库文件,才知道那些标准库里都有啥。

VS添加<bits/stdc++.h>

首先我们需要新建一个文件夹bits,然后创建一个头文件stdc++.h

头文件内容即是万能头里的实质内容

文件内容

// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2017 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

随后我们需要将这个文件夹加入到VS的环境变量中,为了便于头文件的管理,此处我们把这个文件夹跟VS其余头文件放到一起。

便捷操作

首先输入#include<iostream>

右键 – 打开文档

右键 – 打开文件所在位置

复制文件夹进去即可。

其中的路径大家可以参考下。

至此就完成了。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • C++ STL priority_queue自定义排序实现方法详解

    C++ STL priority_queue自定义排序实现方法详解

    这篇文章主要介绍了C++ STL priority_queue自定义排序实现方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-03-03
  • 详谈C语言指针

    详谈C语言指针

    这篇文章主要介绍了C语言的指针,介绍了其相关概念,然后分享了几种用法,具有一定参考价值。需要的朋友可以了解下
    2021-10-10
  • 解决Microsoft Visual C++ 2010 Express 运行及调试问题

    解决Microsoft Visual C++ 2010 Express 运行及调试问题

    这篇文章主要介绍了解决Microsoft Visual C++ 2010 Express 运行及调试问题,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-01-01
  • 基于MFC实现类的序列化详解

    基于MFC实现类的序列化详解

    序列化是将程序中的对象以一种二进制格式存储到存储设备中(例如文本/数据库等),以实现“永生”或随意“流动”。本文将为大家详细讲讲如何基于MFC实现类的序列化,需要的可以参考一下
    2022-07-07
  • C++类中六个默认的成员函数详解

    C++类中六个默认的成员函数详解

    这篇文章主要给大家介绍了关于C++类中六个默认的成员函数的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-04-04
  • VTK8.1 在 Qt5.9 环境下的配置编译和安装过程

    VTK8.1 在 Qt5.9 环境下的配置编译和安装过程

    为了实现realsense的PCL点云显示,需要VTK支持。由于整个平台在Qt环境实现,VTK编译为Qt插件。整个过程并不复杂,网上的文章大多不全,自己梳理了一下,分享出来,需要的朋友可以参考下
    2022-07-07
  • C++中智能指针unique_ptr的实现详解

    C++中智能指针unique_ptr的实现详解

    智能指针本质上并不神秘,其实就是 RAII 资源管理功能的自然展现而已,这篇文章主要为大家详细介绍了如何实现 C++中智能指针的 unique_ptr,需要的可以了解下
    2024-01-01
  • Matlab实现绘制雷达图(蜘蛛图)

    Matlab实现绘制雷达图(蜘蛛图)

    这篇文章主要为大家详细介绍了如何利用Matlab实现雷达图(蜘蛛图)的绘制,文中的示例代码讲解详细,对我们学习Matlab有一定帮助,需要的可以参考一下
    2022-09-09
  • C++类与对象深入之引用与内联函数与auto关键字及for循环详解

    C++类与对象深入之引用与内联函数与auto关键字及for循环详解

    朋友们好,这篇播客我们继续C++的初阶学习,现在对一些C++的入门知识做了些总结,整理出来一篇博客供我们一起复习和学习,如果文章中有理解不当的地方,还希望朋友们在评论区指出,我们相互学习,共同进步
    2022-06-06
  • C语言实现计算器的两种方法

    C语言实现计算器的两种方法

    这篇文章主要为大家详细介绍了C语言实现计算器的两种方法,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-01-01

最新评论