Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

skyscraper's blog

By skyscraper, history, 23 months ago, In English

I was trying to figure out how to include bits/stdc++.h on macos since it uses clang, So once i found the solution i thought of creating a clear video about how to do it.

Video Link : here

 
 
 
 
  • Vote: I like it
  • +26
  • Vote: I do not like it

»
23 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For me this only works in Xcode. It still doesn't compile in CLion or in the terminal.

  • »
    »
    13 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    CLion solution

    1. using finder go to /Library/Developer/CommandLineTools/usr/include/c++/v1
    2. make a folder called bits
    3. make a file called stdc++.h inside bits folder
    4. copy content from _https://github.com/tekfyl/bits-stdc-.h-for-mac/blob/master/stdc%2B%2B.h_ into stdc++.h
    • »
      »
      »
      12 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      I think that isn't enough. With that you still are unable to use tree_policy. The best solution is installing gcc with homebrew.

  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Here is my Clion solution: 1.Install homebrew using the terminal,you can find the needed command on its offical site. 2.Then using command "brew install gcc" ,it will download the compiler antomatically. 3.After the 2nd step is done,check the path of gcc,the command is "brew ls -gcc" (Maybe,cuz it`s been long time since i did this). 4.Open Clion,go Preference,find "toolchain" ,fill the right path into the blank.Save! 5.CLose CLion,reboot your Mac,then everything is done

»
23 months ago, # |
  Vote: I like it +2 Vote: I do not like it

Tbh, it's not worth using bits/stdc++.h. If you type out only the headers you need (with an autocomplete for standard headers maybe), you'll lose some seconds, but on the other hand, you'll save seconds of compilation time because the compiler won't have to go through all the headers on your system and figure out which declarations you need and which ones can be optimised out. When you need to debug and aren't slow at debugging, waiting 2 more seconds for each recompilation can be quite a waste.

  • »
    »
    17 months ago, # ^ |
      Vote: I like it -10 Vote: I do not like it

    I use a precompiled bits/stdc++.h header and my compilation time is around 0.6 seconds

    • »
      »
      »
      16 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How can i get a precompiled bits/stdc++.h header?

      • »
        »
        »
        »
        16 months ago, # ^ |
          Vote: I like it +4 Vote: I do not like it

        Not sure if this will work on Windows but it's worth a try:

        • Find the file stdc++.h which is referenced by the compiler.
        • Compile the file using the same command line options as usual (warnings, optimizations, etc)

        You should get a file called stdc++.pch right next to stdc++.h. Continue using g++ as usual. Next time you compile a file which includesbits/stdc++.h you should see a substantial change in compilation time (2-4 times faster)

    • »
      »
      »
      15 months ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      Why is this down-voted? It's intended way to use bits/stdc++, that's what it was created for.

»
23 months ago, # |
  Vote: I like it 0 Vote: I do not like it

this video help me to solve the same problem, you can change clang to g++ if you like

  • »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    yeah, #include <bits/stdc++.h> will work if you use g++ instead of clang. One side affect is that when debugging, clang can print out the elements of the containers, but g++ can not, which is pretty annoying.

  • »
    »
    16 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks!

  • »
    »
    12 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thank you for the video link, amigo, that's exactly what I was looking for

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Great thanks!

»
23 months ago, # |
  Vote: I like it 0 Vote: I do not like it

First open finder. Then press shift+cmd+G.

Then copy this /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ and paste it in the box. then click Go.

When you're in v1 folder create a new folder called bits after that create a new file called stdc++.h

Then go to this page: https://github.com/tekfyl/bits-stdc-.h-for-mac/blob/master/stdc%2B%2B.h copy the content and paste it in stdc++.h file and save it.

And that's it.

»
16 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Well, I find it necessary to install GCC. With GCC there is also pbds, _Find_first, etc... It’s frustrating for me to be unable to use GCC features on my Mac.

  • »
    »
    16 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    the way i mentioned above, allows us to us pbds... and all gcc libreries, you can change clang to gcc on that way or you can alse compile using g++8

»
15 months ago, # |
  Vote: I like it 0 Vote: I do not like it

bits/stdc++.h is not a standard header file of GNU C++ library. steps: - 1.So go to this location "MinGW\include" and create a folder bits inside include folder. - 2.(https://gist.github.com/rocketrunner22/9b218d3c05aea401fc68da2186dfa364) download the source file and paste it into your bits file. - 3.restart your editor. thank you

»
14 months ago, # |
  Vote: I like it 0 Vote: I do not like it

if you don't have Xcode Installed then go to "Library/Developer/CommandLineTools/usr/include/c++/v1" and create a folder named "bits" download the stdc++.h file from here "https://github.com/tekfyl/bits-stdc-.h-for-mac" and paste it in the "bits" folder. Also, paste the same stdc++.h file in this location: "Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/bits". Restart the Editor for the changes to take place. Happy Coding...

»
14 months ago, # |
  Vote: I like it 0 Vote: I do not like it

thanks for doing this video now I can use the bits/stdc++.h header file.It saved me a lot of time.

»
11 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

I use mac and the following includes do the trick almost all the time (atleast till problem D)

headers
»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I was face a same problem with it. after search couple of hour to fix the ‘bits/stdc++.h’ file not found error

Write a simple tutorial how to fix in macOs and windows fix in ‘bits/stdc++.h’ file not found here is the tutorial link. hope this will help

TUTORIAL

If you have more suggestions please tell me I will add

»
2 months ago, # |
  Vote: I like it -12 Vote: I do not like it

First in CMD, type g++. Then copy the directory where your clang compiler is at. Then go to that directory .../v1/. Then from there, you can see a bunch of other header files. Create a folder named /bits and write a file named stdc++.h into that folder. Copy paste the content into the file: https://github.com/tekfyl/bits-stdc-.h-for-mac/blob/master/stdc%2B%2B.h