关于VS2022不能使用<bits/stdc++.h>的解决方案(万能头文件)

 更新时间:2022年03月20日 15:31:25   作者:MElephant  
#include<bits/stdc++.h>包含了目前 C++ 所包含的所有头文件,又称万能头文件,那么如何在VS2022中使用万能头呢?下面小编给大家代理了关于VS2022不能使用<bits/stdc++.h>的解决方案(万能头文件),感兴趣的朋友一起看看吧

•<bits/stdc++.h>介绍

  #include<bits/stdc++.h>包含了目前 C++ 所包含的所有头文件,又称万能头文件,简直是开挂一般的存在。

  你编程所需要的头文件基本上都囊括在了该万能头文件中,试想一下,将若干行头文件:

#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<vector>
......

  只用一行代码#include<bits/stdc++.h>来代替,是不是简单粗暴!

•如何在VS2022中使用万能头

  可惜,这么好的万能头,在VS2022中不能使用,难道就此放弃吗?

  不,作为21世纪有思想的时代青年,这点问题怎么能难道我呢?

  首先,找到你本地VS的安装目录,在VS中找到 include 文件夹,我的在该路径上:

D:\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include

  在 include 文件夹下创建一个bits 文件夹,并新建一个stdc++.h的文件,将如下代码复制到stdc++.h 文件中,即可在 VS2022 中使用万能头。

// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2016 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 <cuchar>
#include <cwchar>
#include <cwctype>
// 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>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#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>
#if __cplusplus >= 201402L
#include <shared_mutex>

  设置完成后,重启 VS 即可愉悦的使用万能头了,完结撒花!

到此这篇关于VS2022不能使用&lt;bits/stdc++.h&gt;的解决方案的文章就介绍到这了,更多相关VS2022不能使用&lt;bits/stdc++.h&gt;内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • c++之解决char转string时出现的乱码问题

    c++之解决char转string时出现的乱码问题

    这篇文章主要介绍了c++之解决char转string时出现的乱码问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-08-08
  • C语言多线程服务器的实现实例

    C语言多线程服务器的实现实例

    这篇文章主要介绍了C语言多线程服务器的实现实例,文章用实例讲解的很清楚,有对这方面不太懂的同学可以参考下
    2021-02-02
  • Qt音视频开发之利用ffmpeg实现倍速播放

    Qt音视频开发之利用ffmpeg实现倍速播放

    这篇文章主要为大家详细介绍了在Qt音视频开发中如何利用ffmpeg实现倍速播放功能(半倍速/2倍速/4倍速/8倍速),感兴趣的小伙伴可以了解一下
    2022-11-11
  • 与ASCII码相关的C语言字符串操作函数

    与ASCII码相关的C语言字符串操作函数

    这篇文章主要介绍了与ASCII码相关的C语言字符串操作函数,分别是将字符转换为ASCII码的toascii()函数和根据ASCII码进行字符串比较的strcoll()函数,需要的朋友可以参考下
    2015-08-08
  • C++实现通讯录小功能

    C++实现通讯录小功能

    这篇文章主要为大家详细介绍了C++实现通讯录小功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-06-06
  • C语言的递归函数详解

    C语言的递归函数详解

    这篇文章主要为大家介绍了C语言的递归函数,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助
    2022-01-01
  • 简单的socket编程入门示例

    简单的socket编程入门示例

    这篇文章主要介绍了简单的socket编程入门示例,简单实现client输入内容发送到server端输出,需要的朋友可以参考下
    2014-03-03
  • 对比C语言中execv相关的执行文件的三个函数

    对比C语言中execv相关的执行文件的三个函数

    这篇文章主要介绍了对比C语言中execv相关的执行文件的三个函数,分别为execv()函数和execve()函数以及execvp()函数,需要的朋友可以参考下
    2015-08-08
  • Matlab实现数据的动态显示方法

    Matlab实现数据的动态显示方法

    这篇文章主要为大家详细介绍了Matlab使用Plot函数实现数据动态显示方法,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-06-06
  • OpenCV cv.Mat与.txt文件数据的读写操作

    OpenCV cv.Mat与.txt文件数据的读写操作

    这篇文章主要介绍了OpenCV cv.Mat 与 .txt 文件数据的读写操作,现在分享给大家,也给大家做个参考
    2018-05-05

最新评论