I have seen recently that #include
includes every standard library and stl include file. When i try to compile the following code segment
This is non-standard header file, which is known to be part of the libstdc++, which typically comes with GCC. However VS comes with Microsoft's own implementation of the STL, which doen't contain such file. I'd recommend to stop using it and instead include necessary standard headers, like <iostream>
, <vector>
, <string>
, <algorithm>
etc.
Is there any way to avoid this error?
Yes: don't use non-standard header files that are only provided by GCC and not Microsoft's compiler.
There are a number of headers that the C++ standard requires every compiler to provide, such as <iostream>
and <string>
. But a particular compiler's implementation of those headers may rely on other non-standard headers that are also shipped with that compiler, and <bits/stdc++.h>
is one of those.
Think of the standard headers (e.g. <iostream>
) as a "public" interface, and compiler-specific stuff (like everything in bits/
) as the "private" implementation. You shouldn't rely on compiler-specific implementation details if you want your program to be portable to other compilers — or even future versions of the same compiler.
If you want a header that includes all the standard headers, it's easy enough to write your own.