在Clion中使用万能头文件bits/stdc++.h
大部分OJ都支持bits.stdc++.h头文件,也就是说刷题的时候,不需要include那么多头文件,就#include <bits/stdc++.h>
就能包括几乎所有刷题要用的头文件了。但是Mac上的自带的gcc是不支持这个头文件的,所以就需要自行安装。
然后找到最下面的三个include
文件夹,打开中间的那个
右键v1
打开终端,也可以在Finder中打开
创建bits
文件夹
sudo mkdir bits
创建stdc++.h
头文件
sudo vim stdc++.h
按下按键a
开启编辑模式,讲以下内容粘贴进去
1// C++ includes used for precompiling -*- C++ -*-
2
3// Copyright (C) 2003-2014 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file stdc++.h
26 * This is an implementation file for a precompiled header.
27 */
28
29// 17.4.1.2 Headers
30
31// C
32#ifndef _GLIBCXX_NO_ASSERT
33#include <cassert>
34#endif
35#include <cctype>
36#include <cerrno>
37#include <cfloat>
38#include <ciso646>
39#include <climits>
40#include <clocale>
41#include <cmath>
42#include <csetjmp>
43#include <csignal>
44#include <cstdarg>
45#include <cstddef>
46#include <cstdio>
47#include <cstdlib>
48#include <cstring>
49#include <ctime>
50
51#if __cplusplus >= 201103L
52#include <ccomplex>
53#include <cfenv>
54#include <cinttypes>
55#include <cstdbool>
56#include <cstdint>
57#include <ctgmath>
58#include <cwchar>
59#include <cwctype>
60#endif
61
62// C++
63#include <algorithm>
64#include <bitset>
65#include <complex>
66#include <deque>
67#include <exception>
68#include <fstream>
69#include <functional>
70#include <iomanip>
71#include <ios>
72#include <iosfwd>
73#include <iostream>
74#include <istream>
75#include <iterator>
76#include <limits>
77#include <list>
78#include <locale>
79#include <map>
80#include <memory>
81#include <new>
82#include <numeric>
83#include <ostream>
84#include <queue>
85#include <set>
86#include <sstream>
87#include <stack>
88#include <stdexcept>
89#include <streambuf>
90#include <string>
91#include <typeinfo>
92#include <utility>
93#include <valarray>
94#include <vector>
95
96#if __cplusplus >= 201103L
97#include <array>
98#include <atomic>
99#include <chrono>
100#include <condition_variable>
101#include <forward_list>
102#include <future>
103#include <initializer_list>
104#include <mutex>
105#include <random>
106#include <ratio>
107#include <regex>
108#include <scoped_allocator>
109#include <system_error>
110#include <thread>
111#include <tuple>
112#include <typeindex>
113#include <type_traits>
114#include <unordered_map>
115#include <unordered_set>
116#endif
输入:wq
保存并退出,此时就可以正常使用万能头文件了。
除另有声明外,本博客文章均采用 知识共享 (Creative Commons) 署名 4.0 国际许可协议 进行许可。转载请注明原作者与文章出处。