关于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;内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • VS2022永久配置OpenCV开发环境的实现

    目录 下载opencv 添加环境变量 添加项目属性表 配置属性表 在新的项目中快速配置 配置Release模式 本文通过在VS2022中添加并配置项目属性表,实现Opencv永久配置.在不更改opencv文件位置的前提下,只需要在新的项目中添加配置好的项目属性表即可快速完成opencv配置 下载opencv 访问https://opencv.org/releases/,下载适合自己版本的Windows安装文件.注:尽量不要选择最新版本,而是选择老两个版本的安装包 (最新版本的安装包可能会提示缺少

  • opencv4.5.4+VS2022开发环境搭建的实现

    目录 一.下载安装Visual Studio 二.opencv 库的下载 三.修改 path 环境变量 四.配置文件 五.VS配置 六.测试使用 一.下载安装Visual Studio 1.进入:Visual Studio2022的官网,点击Community2022进行下载.2.双击运行VS2022安装包,点击继续,等待几分钟.3.安装程序下载安装验证完毕,将会提示进入这个界面: 选择C++的桌面开发和Visual Studio 扩展开发,右上角打对钩,然后更改安装位置. 注意:修改不了缓存和

  • VS2022实现VC++打包生成安装文件图文详细历程

    目录 首先:打开你的项目文件: 其次:添加新建项目: 第三:点击新建项目 第四:点击下一步 第五:创建程序的快捷方式: 第六: 创建“开始菜单条目”: 第七:生成打包安装程序: 第八:安装程序: 后记: 前言: VC++写好的项目程序,无论你的程序是控制台程序,对话框程序,还是文档程序,最终都是要给客户使用的,要让你的程序在其他电脑平台上使用,必须对项目程序进行打包发布,生成安装程序. 如何生成安装程序: 首先:打开你的项目文件: 打开你想要发布的项目文件,这一步很重要. 其次:添加新建项目:

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

    •<bits/stdc++.h>介绍 #include<bits/stdc++.h>包含了目前 C++ 所包含的所有头文件,又称万能头文件,简直是开挂一般的存在. 你编程所需要的头文件基本上都囊括在了该万能头文件中,试想一下,将若干行头文件: #include<iostream> #include<cstdio> #include<string> #include<map> #include<vector> ......

  • 手动添加bits/stdc++.h到vs2017的详细步骤

    本机环境:win10系统 64位 vs2017 最近码代码时偶然发现了bits/stdc++.h这个头文件(万能头文件),基本上所有的代码只要用了这个头文件就不再写其他头文件了. 看到它就仿佛开启了新世界(也有缺点,就是导致编译速度变慢,不过一般可以忽略不计). [如果安装了MinGW的直接在文件夹里面找到bits这个文件夹,把里面内容复制粘贴到vs的头文件库里面] 1 .新建txt文档,把以下代码(stdc++.h源码)复制进去: // C++ includes used for precom

  • 仿写C语言string.h头文件检验字符串函数

    目录 c语言string.h头文件字符串检验函数仿写 strlen字符串求长度 strcmp / strncmp字符串比较 strchr / strrchr 字符串中查找字符ch 第一个出现的字符ch 最后一个出现的字符ch strstr 字符串匹配:src_str中查找des_str,返回匹配的起始位置,没有为NULL(BF算法) strcpy / strncpy字符串拷贝 strcat / strncat字符串的粘贴 strdup 字符串申请堆区空间存放字符串的副本 总结 c语言string

  • C语言头文件<string.h>函数详解

    目录 1. strlen —— 求字符串长度 1.1 strlen 的声明与用处 1.2 strlen 的用法 1.3 strlen 的模拟实现 2. strcpy —— 字符串拷贝 2.1 strcpy 的声明与用处 2.2 strcpy 的用法 2.3 strcpy 的模拟实现 3. strcmp —— 字符串比较 3.1 strcmp 的声明与用处 3.2 strcmp 的用法 3.3 strcmp 的模拟实现 4. strcat —— 字符串追加 4.1 strcat 的声明与用处 4.

  • C++实现简单信息管理系统

    本文实例为大家分享了C++实现简单信息管理系统的具体代码,供大家参考,具体内容如下 信息管理系统 因为学校布置了写一个信息管理系统的作业,所以写下了这个信息管理系统,这是用cpp写的一个简单程序.基本思路是通过控制台程序,然后通过数字命令来进行操作.该程序编译了多文件:因为是学校的作业所以我把万能头换成了#include"stdc++.h"功能和万能头一致. 该系统使用了链表来链接各个数据.程序的基本功能是打算写两个系统,输入1和账号密码进入学生管理系统输入2和账号密码进入教师管理系统

  • 数据结构之数组Array实例详解

    数据结构之数组Array实例详解 数组Array 基本操作 Status InitArray(int dimm,...)//若维数dim和随后的各维长度合法,则构造相应的数组A,并返回OK Status DestroyArray() //销毁数组A Status Locate(va_list ap,int &off) //若ap指示的各下标值合法,则求出该元素在A中相对地址off Status Value(ElemType &e,...) //A是n维数组,e为元素变量,随后是n个下标值.

  • C语言计算日期差的方法示例

    本文实例讲述了C语言计算日期差的方法.分享给大家供大家参考,具体如下: 历史上,不同的人类聚居地可能有不同的历法,因而记录下来的资料中日期的换算就很麻烦.幸好今天我们统一使用公元纪年法.当然,这种历法对求两个日期差多少天也不是十分简便,但毕竟是可以忍受的. 下面的程序计算了两个日期的差值,两个日期都使用公元纪年法. #include <bits/stdc++.h> using namespace std; int to_day(int y, int m, int d) { int mon[]

  • Ruby学习笔记二帮助生成Vim添加代码头的代码

    脚本语言真是太强了. 我的目的是把我的默认代码头功能加到Vim里面. /****************************************************************************** * COPYRIGHT NOTICE * Copyright (c) 2014 All rights reserved * ----Stay Hungry Stay Foolish---- * * @author : Shen * @name : * @file : G

  • Android引入OpenCV的示例

    简介 在移动开发中,如果我们要实现一些图像处理相关的功能,难免要用到OpenCV.而OpenCV是用c++开发的.我们在Android中,需要使用jni的方法去使用它. 引入配置 我们引入jni开发的基本配置方法,已经在另一篇博客中介绍过了,不再赘述.这一次我们无非是要引入第三方的c++库. 首先,我们找到或新建jniLibs文件夹,然后将依赖的动态库和静态库(路径为OpenCV-android-sdk\sdk\native\libs)拷贝到\src\main\jniLibs下面. 然后,找到c

  • 详解C++中string的用法和例子

    string是C++标准库的一个重要的部分,主要用于字符串处理.可以使用输入输出流方式直接进行操作,也可以通过文件等手段进行操作.同时C++的算法库对string也有着很好的支持,而且string还和c语言的字符串之间有着良好的接口.虽然也有一些弊端,但是瑕不掩瑜. 其中使用的代码多数都是来自cpp官网,因为例子非常全. 声明和初始化方法: 想使用string首先要在头文件当中加入< string > 声明方式也很简单 声明: string s;//声明一个string 对象 string s

随机推荐