GCC vs. Clang: How to use bits/stdc++ header in MacOS
Tags: cpp, compiler, macos
Published: 2020-08-18 14:43:01

# GCC vs CLANG: how to include bits/stdc++.h
For compiling c++, there are many compilers in the market, but 3 of them are very popular. 
1. Visual C++
2. GNU Compiler Collection (GCC)
3. Clang

Among them, Visual C++ was developed by Microsoft, and they don’t support other platforms like Linux. (Typical Microsoft 😛). 

GNU was a project, started by Richard Stallman in 1984, which eventually produced many popular open-source software tools like  Make, Sed, Emacs. GCC was one of them. GCC was used by all UNIX based OS. Apple also used it for macOS. But over time, Apple wanted to add many features to C++ for their own requirements which weren’t accepted well by GNU developers. So Apple engineers made a separate branch for their own version of c++ compiler, which is eventually called CLANG.

And that’s why some features we get GCC but not in CLANG. Most competitive programmers, use `include<bits/stdc++.h` to include all possible header files that might be needed for writing that program. But if we are using macOS, it can’t recognise `include<bits/stdc++.h`.

To solve this problem, 
1. open finder then click `Go to folder`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ho9iwejl5n229fkny2yo.png)
2. paste this address `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/g3y03cf7pb0mw5b4f499.png)
3. Create a new folder name `bits`
4. inside `bits` create a new file named `stdc++.h`. To create a file open terminal and inside that folder and type `touch stdc++.h`
5. paste the code written below inside that file.

```cpp
/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
  */


using namespace std;


  // 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

``` 

save and exit. After that it will work fine. 

originally published in https://saadnoor.com/gcc-vs-clang-how-to-include-bitsstdc-in-mac/