How can I include <bits/stdc++> in Xcode

You can do it by copying stdc++.h file from here: https://gist.github.com/reza-ryte-club/97c39f35dab0c45a5d924dd9e50c445f

Then you can include the file in your c++ file like this:

 //suppose the file is in your home folder, here my username is reza
 #include "/Users/reza/stdc++.h"

Since, bits/stdc++ is a GNU GCC extension, whereas OSX uses the clang compiler.

You have to create bits directory inside /usr/local/include and then make a header file stdc++.h inside bits and paste the contents of this gist inside it. Then, it should compile as expected.


Since, /usr directory is hidden by default on Mac OSX.

  1. Open Finder.
  2. Click Go on menu bar then click Go to folder or Press Command+Shift+G directly.
  3. Enter the path /usr/local/include
  4. Now proceed as mentioned above.

(UPDATE: For latest OS X you need to make folder include inside local and make bits folder inside include folder and then copy paste the code inside bits folder.)


Mac OS X 10.9+ no longer uses GCC/libstdc++ but uses libc++ and Clang.

After the XCode 6.0.1 update the headers are now located here:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1

so, get the stdc++.h file from here,then creat bits directory in the above long address, and copy the file stdc++.h to the bits directory.


You can't. X-Code uses LLVM Toolchain with Clang for the compiler, while <bits/stdc++> is specific to the GNU Compiler Toolchain.

Second, you shouldn't be using that header in the first place, as stated by everyone else.

Tags:

C++

Macos

Xcode