如何运行为旧编译器编写的程序?

tel*_*oon 7 c++ compiler-construction

我正在寻找Hybrid Tree(不重要)的实现,并在这里找到一个"旧"的.

作者说他们已经在SUN Sparc平台(运行Solaris 2.6)和gcc-2.8.1编译器上尝试了这个代码.我的环境是gcc版本4.4.3(Ubuntu 10.10).

问题是:我用他提供的makefile运行"make",但它给了我很多错误信息,如下所示:

g++  -c  Node.C
g++  -c  DataNode.C
In file included from DataNode.h:18,
                 from DataNode.C:17:
Query.h:9:20: error: vector.h: No such file or directory
Query.h:10:19: error: stack.h: No such file or directory
Query.h:13:22: error: function.h: No such file or directory
Query.h:14:22: error: iostream.h: No such file or directory
DataNode.C:283:8: warning: extra tokens at end of #endif directive
In file included from DataNode.h:18,
                 from DataNode.C:17:
Query.h:29: warning: ‘typedef’ was ignored in this declaration
Query.h:44: warning: ‘typedef’ was ignored in this declaration
Query.h:86: error: expected initializer before ‘<’ token
Query.h:118: error: ISO C++ forbids declaration of ‘PQ’ with no type
Query.h:118: error: expected ‘;’ before ‘*’ token
Query.h:122: error: ISO C++ forbids declaration of ‘PQ’ with no type
Query.h:122: error: expected ‘;’ before ‘*’ token
Query.h:126: error: ISO C++ forbids declaration of ‘PQ’ with no type
Query.h:126: error: expected ‘;’ before ‘*’ token
Query.h:135: error: expected initializer before ‘<’ token
DataNode.C: In member function ‘void DataNode::DisconnectBranch(int)’:
DataNode.C:80: error: ‘memmove’ was not declared in this scope
make: *** [DataNode.o] Error 1
Run Code Online (Sandbox Code Playgroud)

我知道我需要修改源代码以便同意现代编译器,例如更改vector.hvector.但我觉得这是无止境的.

所以我的问题是:是否有任何方便运行此程序,无论是自动将此代码转换为"现代风格"还是使用独立的"旧式"编译器?

有什么建议?

=== 更新: ===

谢谢大家,我在另一个dir中安装了gcc2.8.1 --prefix=/usr/local/gcc-2.8.1并修改了"makefile"来使用这个旧版本的gcc(/usr/local/gcc-2.8.1/bin/gcc).但是当我运行"make"时,它仍然给我错误找不到标题:

/usr/local/gcc-2.8.1/bin/gcc  -c  DataNode.C
In file included from DataNode.h:18,
                 from DataNode.C:17:
Query.h:9: vector.h: No such file or directory
Query.h:10: stack.h: No such file or directory
Query.h:11: deque: No such file or directory
Query.h:12: algorithm: No such file or directory
Query.h:13: function.h: No such file or directory
Query.h:14: iostream.h: No such file or directory
make: *** [DataNode.o] Error 1
Run Code Online (Sandbox Code Playgroud)

然后我试图在/usr/local/gcc-2.8.1中找到这些头find /usr/local/gcc-2.8.1 -name "*vector*",但什么都没有.

那么旧版gcc的这些头部在哪里?

小智 8

你可以自己制作一个包含矢量的vertor.h.这样,您可以无创地修复不兼容性.

编辑:

您可能还需要using namespace std; 在头文件中添加一个 .这通常是一个坏主意,但这是我无论如何都要这样做的情况.

一旦你得到它的工作,我会建议重写它以使用新的样式头文件和命名空间.