Linux 从哪里获取 iostream.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3698267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:08:23  来源:igfitidea点击:

Where to get iostream.h

linuxg++makefiledebian

提问by node ninja

I'm trying to make something in Linux, but it complains that it can't find iostream.h. What do I need to install to get this file?

我正在尝试在 Linux 中制作一些东西,但它抱怨找不到 iostream.h。我需要安装什么才能获得这个文件?

回答by Johnsyweb

The correct name of this standard header is just iostreamwithout an extension.

这个标准头的正确名称只是iostream没有扩展名。

If your compiler still cannot find it, try the following:

如果您的编译器仍然找不到它,请尝试以下操作:

find /usr/include -name iostream -type f -print

...and add it to your include path, following your compiler's documentation.

...并按照编译器的文档将其添加到包含路径中。

回答by Michael Aaron Safyan

The header <iostream.h> is an antiquated header from before C++ became standardized as ISO C++ 1998 (it is from the C++ Annotated Reference Manual). The standard C++ header is <iostream>. There are some minor differences between the two, with the biggest difference being that <iostream> puts the included contents in namespace std, so you have to qualify cin, cout, endl, istream, etc. with "std::". As somewhat of a hack (it is a hack because header files should never contain "using" directives as they completely defeat the purpose of namespaces), you could define "iostream.h" as follows:

标头 <iostream.h> 是 C++ 标准化为 ISO C++ 1998 之前的过时标头(它来自 C++ Annotated Reference Manual)。标准的 C++ 头文件是 <iostream>。两者之间有一些细微的区别,最大的区别是 <iostream> 将包含的内容放在命名空间 std 中,因此您必须使用“std::”来限定 cin、cout、endl、istream 等。作为某种黑客行为(这是一种黑客行为,因为头文件不应该包含“using”指令,因为它们完全违背了命名空间的目的),您可以如下定义“iostream.h”:

#ifndef HEADER_IOSTREAM_H
#define HEADER_IOSTREAM_H

#include <iostream>
using namespace std; // Beware, this completely defeats the whole point of
                     // having namespaces and could lead to name clashes; on the
                     // other hand, code that still includes <iostream.h> was
                     // probably created before namespaces, anyway.

#endif

While this is not exactly identical to the original antiquated header, this should be close enough for most purposes (i.e. there should be either nothing or very few things that you will have to fix).

虽然这与原始过时的标头并不完全相同,但对于大多数用途来说,这应该足够接近(即应该没有或只有很少的事情需要修复)。

回答by Geraldo

I need to compile partport on debian and had problems (centos 4.5 works fine) I did this without no success ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h

我需要在 debian 上编译 partport 并且有问题(centos 4.5 工作正常)我这样做没有成功 ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h

I discover that iostream.h provides from c++ and I found it on centos 4.5

我发现 iostream.h 从 c++ 提供,我在 centos 4.5 上找到它

so I copied from centos 4.5 to ubuntu natty the file iostream.h and it worked
scp [email protected]:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5/iostream.h

所以我从centos 4.5复制到ubuntu
natty文件iostream.h并且它工作了scp [email protected]:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5 /iostream.h