Back to articles
Stop using #include <bits/stdc++.h>. Your compiler will thank you!

Stop using #include <bits/stdc++.h>. Your compiler will thank you!

via Dev.toAryaveer Singh

If you've spent any time in the competitive programming world, you know and love #include <bits/stdc++.h> . It’s the ultimate time-saver, a magic bullet that imports almost the entire standard library at once. No more worrying about whether you forgot to include <vector> or <algorithm> . But what happens when you move from writing a quick competitive programming solution to building a massive, multi-file software project? That magic bullet suddenly turns into a massive bottleneck. Let's dive into exactly why this happens, how the C++ compiler processes your code, and the modern C++20 solution that is changing the game. The "Old Way": The 4-Step Compilation Process To understand the problem, we have to look at how C++ compilation was designed back in the 1970s. It fundamentally follows a "copy-paste" philosophy across four steps: Source Code ( .cpp ): This is the code you write. Preprocessing ( .i ): The preprocessor scans for # symbols. When it sees #include <vector> , it physically op

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles