#include< bits/stdc ++.h>用Visual Studio无法编译 [英] #include <bits/stdc++.h> with visual studio does not compile

查看:830
本文介绍了#include< bits/stdc ++.h>用Visual Studio无法编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近看到#include <bits/stdc++.h>包括每个标准库和stl包含文件.当我尝试使用Visual Studio 2013编译以下代码段时,它给出一个error C1083: Cannot open include file: 'bits/stdc++.h': No such file or directory.但是,它与代码块完美配合.有什么办法可以避免此错误?

I have seen recently that #include <bits/stdc++.h> includes every standard library and stl include file. When i try to compile the following code segment with visual studio 2013, it gives an error C1083: Cannot open include file: 'bits/stdc++.h': No such file or directory. But it works perfectly fine with codeblocks. Is there any way to avoid this error?

#include <bits/stdc++.h>

using namespace std;

int main()
{

}   

我在一些帖子中看到头文件不是C ++标准的一部分,因此是不可移植的,应避免使用".但是我认为这对比赛编程很有帮助.

I saw in some post that 'the header file is not part of the C++ standard, is therefore non-portable', and should be avoided'. But i think it is helpful in contest programming.

推荐答案

有什么办法可以避免此错误?

Is there any way to avoid this error?

是的:不要使用仅由GCC而不是Microsoft的编译器提供的非标准头文件.

Yes: don't use non-standard header files that are only provided by GCC and not Microsoft's compiler.

C ++标准要求每个编译器提供许多标头,例如<iostream><string>.但是特定编译器对这些标头的实现可能依赖于该编译器还附带的其他非标准标头,而<bits/stdc++.h>就是其中之一.

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.

将标准标头(例如<iostream>)视为公共"接口,将特定于编译器的内容(如bits/中的所有内容)视为私有"实现.如果您希望程序可以移植到其他编译器,甚至 same 编译器的将来版本,也不要依赖于特定于编译器的实现细节.

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.

这篇关于#include&lt; bits/stdc ++.h&gt;用Visual Studio无法编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆