mac如何在clang下使用"bit/stdc++.h"

因为mac默认的c++编译器为clang,虽然clang比gcc部分上要优秀一些,但是在clang下没有自带”bits/std++.h”的头文件,而竞赛的同学一般喜欢用这个头文件。
所以曲线救国一下。。
由于本人使用的sublime,不用xcode,想到c语言老师教我们的可以自己创建头文件的骚操作。所以此方法不需要借助xcode或其他软件。
主要思路:在clang的头文件下添加一个”bits/stdc++.h”头文件。
1.首先要看一下头文件所在位置。在访达中按组合键 shift+commond+G访问隐藏的文件。在弹出的框中输入/usr并前往。
这里写图片描述
2.查看include文件夹权限。
这里写图片描述
这里写图片描述
如果你的权限不是图中所显示的,应该修改权限,因为我们要在include的文件夹下写入文件。如果不能直接修改权限可以参考如何修改文件权限
3.修改完权限后,就可以在include的文件夹中添加一个名为:bits的文件夹。
这里写图片描述
4.打开文本编辑,新建文件,设置格式为纯文本。保存以下头文件:

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2014 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 <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

保存到/usr/include/bits的位置。(还是需要组合键shift+commond+G)命名为stdc++.h。
这样就可以愉快的使用bits/stdc++.h啦!

猜你喜欢

转载自blog.csdn.net/qq_39921637/article/details/82418334