免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 9672 | 回复: 3
打印 上一主题 下一主题

[C++] 老代码的纠错问题【iostream.h和fstream.h】 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-11-03 21:38 |只看该作者 |倒序浏览
5可用积分
在Debian下面执行sudo make时,线上遇到了找不到gmake命令的问题,后来用sudo ln -s /usr/bin/make /usr/bin/gmake添加链接解决了该问题。

再执行sudo make时,出现了如下的错误问题。
cd ./src/app; gmake all
gmake[1]: Entering directory `/home/jjj/svp-1.0b0/src/app'
cd ../libvd; gmake all
gmake[2]: Entering directory `/home/jjj/svp-1.0b0/src/libvd'
c++ -c  -funsigned-char -DLIBVD_VERSION=\"1.0b0\" -I. -I/usr/local/svp/include -I. table.C
In file included from table.H:10,
                 from table.C:4:
./object.H:5:22: error: iostream.h: 没有那个文件或目录
table.C:14:21: error: fstream.h: 没有那个文件或目录
In file included from table.H:10,
                 from table.C:4:
./object.H:39: error: ‘ostream’ has not been declared
./object.H:40: error: ‘istream’ has not been declared
./object.H:84: error: expected initializer before ‘&’ token
./object.H:91: error: expected initializer before ‘&’ token
In file included from table.C:16:
./array.H:39: error: ‘ostream’ has not been declared
./array.H:88: error: ‘ostream’ has not been declared
./array.H:110: error: expected unqualified-id before ‘!’ token
In file included from table.C:17:
./strings.H:49: error: ‘ostream’ has not been declared
./strings.H:50: error: ‘istream’ has not been declared
table.C: In member function ‘void TTable::destroy()’:
table.C:187: warning: deleting ‘void*’ is undefined
table.C: In member function ‘int TTable::read(const char*, bool, int)’:
table.C:486: error: ‘ifstream’ was not declared in this scope
table.C:486: error: expected `;' before ‘in’
table.C:487: error: ‘in’ was not declared in this scope
table.C:491: error: ‘in’ was not declared in this scope
gmake[2]: *** [table.o] 错误 1
gmake[2]: Leaving directory `/home/jjj/svp-1.0b0/src/libvd'
gmake[1]: *** [libvd] 错误 2
gmake[1]: Leaving directory `/home/jjj/svp-1.0b0/src/app'
make: *** [app] 错误 2

按照网上的提示,将
#include <iostream.h>
改成了
#include <iostream>
using namespace std;


#include <fstream.h>
改成了
#include <fstream>
using namespace std;

再执行sudo make时又出现了错误
cd ./src/app; gmake all
gmake[1]: Entering directory `/home/jjj/svp-1.0b0/src/app'
cd ../libvd; gmake all
gmake[2]: Entering directory `/home/jjj/svp-1.0b0/src/libvd'
c++ -c  -funsigned-char -DLIBVD_VERSION=\"1.0b0\" -I. -I/usr/local/svp/include -I. table.C
In file included from table.C:16:
./array.H:110: error: expected unqualified-id before ‘!’ token
table.C: In member function ‘void TTable::destroy()’:
table.C:188: warning: deleting ‘void*’ is undefined
gmake[2]: *** [table.o] 错误 1
gmake[2]: Leaving directory `/home/jjj/svp-1.0b0/src/libvd'
gmake[1]: *** [libvd] 错误 2
gmake[1]: Leaving directory `/home/jjj/svp-1.0b0/src/app'
make: *** [app] 错误 2

顺便将程序代码用附件上传了,请高手指点,本人是菜鸟,解答的越详细越好,先行谢过了!!

[ 本帖最后由 wxjiao 于 2009-11-3 21:39 编辑 ]

svp-1.0b0.zip

136.35 KB, 下载次数: 51

最佳答案

查看完整内容

其实没什么错误,就是有些声明和语法不对。iostream.h不再直接包含了,而是包含iostream,然后使用std命名空间。fstream类似。math.h中一些函数原型,跟它里面声明的不太一样。现在的C++编译器不再支持函数定义中加默认值了,只可以在声明中加。主要就这三条,改了就好了。

论坛徽章:
0
2 [报告]
发表于 2009-11-03 21:38 |只看该作者
其实没什么错误,就是有些声明和语法不对。

iostream.h不再直接包含了,而是包含iostream,然后使用std命名空间。fstream类似。
math.h中一些函数原型,跟它里面声明的不太一样。
现在的C++编译器不再支持函数定义中加默认值了,只可以在声明中加。

主要就这三条,改了就好了。

svn-1.0b0-change-by-Alf.tar.bz2

310.38 KB, 下载次数: 127

论坛徽章:
0
3 [报告]
发表于 2009-11-03 22:26 |只看该作者
非常感谢naihe2010的帮助,使用您修改的版本,软件已经装好了。实在是没分悬赏了,只能口头感谢了呵。以后有问题还向您多请教。

论坛徽章:
0
4 [报告]
发表于 2009-11-04 08:54 |只看该作者
晕。我还得倒贴点儿!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP