Hello Everyone!
I am currently using Windows 10. I run my C++ code in Sublime Text 3 which take around more than 2 sec to run a code which is too slow (I am just printing a variable). I have also tried to include precomplied header for stdc++.h but still running time is same. Can somebody please help me with this issue ?
Thank You
Don't include the stdc++.h header file, rather include the required header files manually to decrease the compile time.
It decreases the time by 1sec when I am only including iostream but as I have already precompiled stdc++.h it should not take much time.
I think you did something wrong on precompiling. In my case, precompiling reduced the compile time of bits/stdc++.h to about 0.7s.
#include "bits/stdc++.h"
instead of#include <bits/stdc++.h>
? Only the first one work with precompilation.Check these two. It will just use original non-precompiled stdc++.h file if one of those two fails.
I am using the first point correctly .
Regarding second point I do not understand the location of path much but the path of my precompiled file is
C:\Program Files\mingw-w64\mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\x86_64-w64-mingw32\bits\stdc++.h.gch .
Is it correct?
I don't know much about technical stuff so I can't judge whether that'll work or not. I can only say whether yours differ from mine.
In my case, I made a
bits
file within the SAME folder as mysource.cpp
file. mystdc++.pch
is located within that newbits
file I've created.Here
a.cpp
is my source code file,bits
andext
contains my precompiled header filesstdc++.pch
andpb_ds
stuffs respectively.I tried putting my source cpp file in the folder that is in the picture but it is still showing 2 sec. I think there should be a way to tell sublime explicitly that precompiled files are in a particular path.
Btw the compilation command matters too. The commands you used to precompile your header must match the command you're using to run your executable.
Version matters too. If you precompile your header with C++14, it won't work when you run your executable with C++17.
In the build system I am using C++ Single File. How can I get the information about what are the flags and version this build system is using?
Not entirely sure (I use a custom build system). I think you should be able to find it on google tho.
Thank you so much for your help. It really helped a lot.
hey did you get it? Ostrich888
Sorry but I didn't get it
What is difference between
"bits/stdc++.h"
and<bits/stdc++.h>
?Make sure that you compiled stdc++.h with your compilation flags. For example, my flags are
so I would compile stdc++.h with those flags.
I precompiled it with command
Can you please tell how to check what flags I am using because for running the code I just use CTRL+B in Sublime text.
IDK how to do it for Sublime Text... Maybe ask someone that uses Sublime Text? I use Vim BTW.
custom build for c++ in sublime text
east or west, codeblocks is best :D