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
# | User | Rating |
---|---|---|
1 | tourist | 3778 |
2 | Benq | 3592 |
3 | ecnerwala | 3521 |
4 | Um_nik | 3423 |
5 | jiangly | 3375 |
6 | Petr | 3342 |
7 | Radewoosh | 3337 |
8 | scott_wu | 3313 |
9 | maroonrk | 3265 |
10 | yosupo | 3259 |
# | User | Contrib. |
---|---|---|
1 | 1-gon | 205 |
2 | Errichto | 201 |
3 | rng_58 | 194 |
3 | SecondThread | 194 |
5 | awoo | 186 |
6 | vovuh | 183 |
7 | Um_nik | 182 |
8 | antontrygubO_o | 177 |
9 | Ashishgup | 175 |
10 | -is-this-fft- | 171 |
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
Name |
---|
For me this only works in Xcode. It still doesn't compile in CLion or in the terminal.
CLion solution
I think that isn't enough. With that you still are unable to use
tree_policy
. The best solution is installinggcc
withhomebrew
.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.I use a precompiled
bits/stdc++.h
header and my compilation time is around 0.6 secondsHow can i get a precompiled bits/stdc++.h header?
Not sure if this will work on Windows but it's worth a try:
stdc++.h
which is referenced by the compiler.You should get a file called
stdc++.pch
right next tostdc++.h
. Continue usingg++
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)Why is this down-voted? It's intended way to use bits/stdc++, that's what it was created for.
this video help me to solve the same problem, you can change clang to g++ if you like
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.
Thanks!
Thank you for the video link, amigo, that's exactly what I was looking for
Great thanks!
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.
Thanks a lot.
Thank you. It's working.
Thank you so much!
bits/stdc++.h disappears everytime I update Xcode, is there any way to fix this?
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.
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
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
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...
Good tip. Thanks.
thanks for doing this video now I can use the bits/stdc++.h header file.It saved me a lot of time.
I use mac and the following includes do the trick almost all the time (atleast till problem D)
iostream
vector
map
stack
queue
set
algorithm
cassert
...