0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Xcodeでbits/stdc++.hをインクルード

Last updated at Posted at 2021-12-11

OSを更新したところXcodebits/stdc++.hが使えなくなってしまいました.
試行錯誤しているうちに、使えるようになったので忘れる前に行った手順を書き留めておきます.
どなたかのお役に立てれば幸いです.

1. Xcodeのincludeフォルダに移動

ターミナルを開き以下のフォルダに移動します.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1

2. bitsフォルダを作る

bitsフォルダを作ります
permission deniedが出た場合はsudoをつけてください(パスワードの入力が求められます).

mkdir bits
sudo mkdir bits

3. bitsフォルダに移動

現在v1にいると思うので先ほど作ったbitsフォルダに移動します.

cd bits

4. stdc++.hファイルを作成

bitsフォルダにstdc++.hファイルを作ります. permission deniedが出た場合はsudoをつけましょう.

touch stdc++.h
sudo touch stdc++.h

5. stdc++.hファイルを編集

作成したstdc++.hファイルを開いて以下の内容をコピペ,保存してください.
保存ができれば編集するエディタはなんでも大丈夫だと思います.
内容は以下のサイトを参考としています.
https://gist.github.com/reza-ryte-club/97c39f35dab0c45a5d924dd9e50c445f

stdc++.h
// C++ includes used for precompiling -*- C++ -*-

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

<Vimで編集する場合>
(1) Vimで開く

vi stdc++.h
sudo vi stdc++.h

(2) stdc++.hの内容をコピー(選択した範囲のコピーは「Command」+「C」でできます)
(3) ペースト(「Command」+「V」)
(4) 保存して(強制)終了

:wq!    // Vimのコマンドモードで行います

6.終わりに

これでXcodebits/stdc++.hが使えるようになったと思います.
OSの更新などの理由で, この手順が使えなくなってしまう可能性があるので一応現在の環境を記しておきます.
macOS Monterey Version 12.0.1
Xcode Version 13.1

#参考
OSをアップデートする前, 大変お世話になりました.
Xcodeでbits/stdc++.hをインクルードする

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?