iostream.h,找不到fstream.h [英] iostream.h, fstream.h cannot be found

查看:127
本文介绍了iostream.h,找不到fstream.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台32位计算机,并且正在其上运行Ubuntu 9.10.我有最新的gcc编译器.我面临的问题是我有一个2002年开发的库.代码肯定是正确的,但是当我尝试构建它时,它给了我类似iostream.h的错误,找不到:错误:fstream.h:没有这样的错误文件或目录等.有很多文件,因此我无法更改它们.

I have a 32 bit machine and I am running Ubuntu 9.10 on it. I have the latest gcc compiler. The problem that I am facing is that I have a library developed in 2002. The code is correct for sure but when I try to built it, it gives me errors like iostream.h cannot be found, error: fstream.h: No such file or directory etc etc. There are lots of files hence I cannot change them.

如果我安装了gcc 3.0,可以解决这些错误吗?如果是,如何在现有的gcc编译器上安装它.

Can these errors be solved if solved I install gcc 3.0 ? If yes how to install it over my existing gcc compiler.

推荐答案

您正在处理一个标准的C ++库,并且您已经看到它无法使用标准的编译器进行编译.您始终可以通过使用两行#include <iostream>using namespace std;创建iostream.h来尝试快速解决方法,这可能会起作用.它不可靠,并且可能会导致难以发现的错误,这些错误会在不方便的时间出现.

You're dealing with a pre-standard C++ library, and you've seen it won't compile with a standard compiler. You can always try the quick work-around by creating, say, iostream.h with the two lines #include <iostream> and using namespace std;, and that may work. It isn't reliable, and may cause hard-to-find bugs that will appear at an inconvenient time.

如果这是其他地方的图书馆,您可以查看它是否已更新.

If this is a library from somewhere else, you could see if it's been updated.

要意识到的是代码不再正确.在某些时候对于某些实现来说可能是正确的,但现在不是. (您确定它最初是针对gcc 3.0的吗?预标准的编译器是标准的,不是标准的,并且有很多奇怪之处.避免这样做是为了标准.)如果您确实安装了原始系统,则可能无法正确地与库连接,新代码将无法正常工作.不与现代代码交互的库用途有限.

The thing to realize is that the code isn't correct anymore. It may have been correct for some implementation at some time, but it isn't now. (Are you sure it was originally for gcc 3.0? Pre-standard compilers were, well, not standard, and had a lot of oddities. Avoiding that is what standards are for.) If you do install the original system, you may be unable to interface with the library properly, and new code isn't going to work. A library that doesn't interface with modern code is of limited use.

否则,您将不得不放弃无法更改库的态度,并将其转换为标准C ++.可能会存在很多相当容易修复的错误(例如for (int i = 0;...)中的范围),并且可能存在一些更小的问题.该代码对于某些编译器可能是正确的,但现在不是.

Otherwise, you're going to have to abandon the attitude that you can't change the library, and convert it to standard C++. There will likely be quite a few bugs that are fairly easy to fix (like the scope in for (int i = 0;...)), and may be some subtler problems. The code may have been correct for a certain compiler, but it isn't now.

这篇关于iostream.h,找不到fstream.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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