<bits/stdc++.h>

Apr 10, 2018 at 4:27pm
Does #include <bits/stdc++.h> slow your program ?
Apr 10, 2018 at 5:19pm
In comparison to including the correct headers, using this internal GCC header may result in slower compilation (not execution):

1
2
3
4
5
#include <cstdlib>
int main()
{
    return EXIT_FAILURE;
}

this compiled in 0.1 seconds (best of 5)
$ time g++ -O3 -Wall -pedantic-errors -o test test.cc
real    0m0.136s
user    0m0.046s
sys     0m0.037s


1
2
3
4
5
#include <bits/stdc++.h>
int main()
{
    return EXIT_FAILURE;
}

this compiled in 1.5 seconds (best of 5 runs)
$ time g++ -O3 -Wall -pedantic-errors -o test test.cc
real    0m1.533s
user    0m1.303s
sys     0m0.181s


that's 11 times slower

More importantly, "#include <bits/stdc++.h>" means you're no longer using C++: your program can't be used with any other compiler, a future version of GCC may choose to drop or change that header, and you won't be able to use this at work.

Apr 10, 2018 at 5:53pm
i dont understand the difference between compilation time and execution time, execution time is the one that matters in contests or the compilation time? i dont understand this
Apr 10, 2018 at 6:14pm
compile time is how long it takes to turn c++ code into an executable program.
execution time is how long it takes your code to run when you USE it.
Apr 10, 2018 at 6:24pm
"#include <bits/stdc++.h>" means you're no longer using C++

Including a non-standard header file doesn't mean you are not using C++.
Apr 10, 2018 at 7:21pm
closed account (E0p9LyTq)
More importantly, "#include <bits/stdc++.h>" means you're no longer using C++

Just means the C++ being used is non-standard and not portable.

Can be a real headache when the compiler gets upgraded, or use switches to be strict standard conformant.
Topic archived. No new replies allowed.