C++無法打開源文件bits/stdc++.h的問題
VS 是不支持 萬能頭的,需要我們自己去手動添加。
原理
首先我們得知道萬能頭是個啥東西。(其實(shí)是我不知道。。QAQ)<bits/stdc++.h>
其實(shí)就是一個頭文件,里面包含了幾乎所有的C++庫里的頭文件。
因此一般只需要包含這一個頭文件就能滿足所有的需求。
不過自然也會有著一些缺點(diǎn)。
優(yōu)點(diǎn)
- 簡單便捷。能滿足大多數(shù)場合,即一些對運(yùn)行需求不大嚴(yán)格的場合。
- 節(jié)省時間,不必考慮需要加入哪些頭文件。這對參與競賽的時候能起到一點(diǎn)幫助。
缺點(diǎn)
- 包含所有的頭文件,編譯時速度自然就稍慢一些,增加編譯時間。
- 這不是C++的標(biāo)準(zhǔn)庫,因而不是所有的編譯系統(tǒng)都有,比如一些OJ就可能沒有。
- 不建議新手使用,新手還是要多用用庫文件,才知道那些標(biāo)準(zhǔn)庫里都有啥。
VS添加<bits/stdc++.h>
首先我們需要新建一個文件夾bits
,然后創(chuàng)建一個頭文件stdc++.h
。
頭文件內(nèi)容即是萬能頭里的實(shí)質(zhì)內(nèi)容。
文件內(nèi)容
// 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的環(huán)境變量中,為了便于頭文件的管理,此處我們把這個文件夾跟VS其余頭文件放到一起。
便捷操作
首先輸入#include<iostream>
。
右鍵 – 打開文檔
右鍵 – 打開文件所在位置
復(fù)制文件夾進(jìn)去即可。
其中的路徑大家可以參考下。
至此就完成了。
總結(jié)
以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
單鏈表實(shí)現(xiàn)反轉(zhuǎn)的3種方法示例代碼
單鏈表的反轉(zhuǎn)是常見的面試題目,下面這篇文章主要給大家介紹了關(guān)于單鏈表實(shí)現(xiàn)反轉(zhuǎn)的3種方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-02-02C語言深入探究水仙花數(shù)與變種水仙花數(shù)代碼
求水仙花數(shù)和變種水仙花數(shù)是非常適合初學(xué)者學(xué)習(xí)的代碼,其中包含的循環(huán)和邏輯方式等知識點(diǎn)。這既能起到對以往知識的復(fù)習(xí),也可以學(xué)習(xí)到一種不同的邏輯思考方式2022-05-05使用VS2019編譯CEF2623項(xiàng)目的libcef_dll_wrapper.lib的方法
這篇文章主要介紹了使用VS2019編譯CEF2623項(xiàng)目的libcef_dll_wrapper.lib的方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04C++中繼承與多態(tài)的基礎(chǔ)虛函數(shù)類詳解
這篇文章主要給大家介紹了關(guān)于C++中繼承與多態(tài)的基礎(chǔ)虛函數(shù)類的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-09-09