patterncppCritical
Why should I not #include <bits/stdc++.h>?
Viewed 0 times
bitsstdcwhyshouldnotinclude
Problem
I posted a question with my code whose only
My teacher told me to do this, but in the comments section I was informed that I shouldn't.
Why?
#include directive was the following:#include My teacher told me to do this, but in the comments section I was informed that I shouldn't.
Why?
Solution
Including `
The disadvantages include:
Don't do it!
More information:
Example of why Quora is bad:
appears to be an increasingly common thing to see on Stack Overflow, perhaps something newly added to a national curriculum in the current academic year.
I imagine the advantages are vaguely given thus:
- You only need write one
#include line.
- You do not need to look up which standard header everything is in.
Unfortunately, this is a lazy hack, naming a GCC internal header directly instead of individual standard headers like , and `. It ruins portability and fosters terrible habits.The disadvantages include:
- It will probably only work on that compiler.
- You have no idea what it'll do when you use it, because its contents are not set by a standard.
- Even just upgrading your compiler to its own next version may break your program.
- Every single standard header must be parsed and compiled along with your source code, which is slow and results in a bulky executable under certain compilation settings.
Don't do it!
More information:
- #include with visual studio does not compile
- How does #include work in C++?
Example of why Quora is bad:
- Is it good practice to use #include in programming contests instead of listing a lot of includes?
Context
Stack Overflow Q#31816095, score: 541
Revisions (0)
No revisions yet.