使用 #include < iostream.h>
Use of #include <iostream.h>
我正在做一个旧的项目,它仍然有不推荐的"#include iostream.h"包含。我知道iostream.h已被弃用,不应该使用,但是这段代码必须在一些运行CC的旧solaris机器上运行/编译,并且没有iostream可用。我的问题是:我怎样才能使我的更现代的c++编译器接受iostream.h的包含。
编辑:编译器找不到iostream.h文件,所以我假设没有。h版本的库可用于g++。最简单的解决方案可能是创建一个名为iostream.h
的本地头文件,该文件仅包含<iostream>
并导入命名空间std
。然后,为了使编译器允许#include <iostream.h>
,您将本地路径添加到包含文件搜索路径中。对于g++,这可以工作:
g++ -I local_folder [other flags] …
顺便提一下,你对
的评论…弃用的"#include iostream.h"
是不完全正确的:这并没有被弃用,因为它从来不是合法的c++。
我会退一步,写另一个你在任何地方使用的中间头,而不是像这样:
#if defined(sun) || defined(__sun)
# if defined(__SVR4) || defined(__svr4__)
/* Solaris */
#include <iostream>
# else
/* SunOS */
#include "iostream.h"
# endif
#else
/* Sane, modern system */
#include <iostream>
#endif
相关文章:
- 是否可以用"iostream"包装现有的TCP/OOpenSSL会话
- 需要从 istream 和 ostream 派生 iostream
- EASTL矢量<向量<int>>连续的
- std::带有自定义缓冲区的 iostream 不允许我写入
- 新的放置取决于 iostream
- 包含在 <initializer_list> <iostream>?
- 为什么在包含iostream时可以使用printf()?
- 如果 iostream 对象不可复制,为什么以下代码是合法的?
- 为什么我必须在包含后写 std::cin <iostream>?
- 如何将带有空字符的字节数组馈送到 std::iostream 中?
- 磁力计代码:C++ vs C - iosstream,矢量 - 错误iostream:没有这样的文件或目录
- 通过boost asio iostream下载大文件的最快方法是什么?
- 为什么 VScode 在 .h 文件中显示"'iostream' file not found"?
- 包含iostream导致不同的二进制文件
- iostream运算符重载的C++异常规范
- basic_iostream和iostream之间的区别
- iostream 和 fstream 的重载<<
- Borland C++编译器中的Iostream
- 从类模板继承时需要iostream
- 为什么<iostream>依赖MinGW dll?