"cannot open source file bits/stdc++.h" in Visual Studio
It's an internal GCC header file. There is no guarantee that it will work anywhere else; even using it with GCC itself is poor practice for many reasons. Do not use it, ever.
How can I fix this?
Include those standard headers which you actually need. For example, if you need std::cout
, then include <iostream>
. If you need std::string
, then include <string>
. If you need std::ifstream
, then include <fstream>
.
As those are standard headers, they are guaranteed to work everywhere.
cppreference.com is a good free online source to find out which headers are needed for which component of the standard library. Let's take a non-obvious one, like std::ifstream
. You just search for that name and you'll find http://en.cppreference.com/w/cpp/io/basic_ifstream. There, it says:
Defined in header
<fstream>
Gooz
Updated on April 17, 2020Comments
-
Gooz about 4 years
#include <bits/stdc++.h>
If I put the above line at the top of my
program.cpp
file, it gives me the following error message:cannot open source file "bits/stdc++.h"
How can I fix this?