C++ 编译旧C++;用于windows的unix应用程序

C++ 编译旧C++;用于windows的unix应用程序,c++,gcc,cygwin,C++,Gcc,Cygwin,我需要一个windows可执行文件,用于一些1994年为UNIX编写的代码。我试着在cygwin环境中这样做。C++标准从这个时候和标准库也被改变了。 我尝试使用-std=和-traditional cpp选项,但这些选项对我毫无帮助。我还发现作用域的-fno和-fno操作符名称减少了错误的数量。从那时起,输入/输出库也发生了重大变化。我还认为,从那时起,预定义的(由预处理器)宏也可能发生变化 代码的作者注释: 库中的C代码(库/linpack和库/配方)使用以下方法编译: gcc -c *.c

我需要一个windows可执行文件,用于一些1994年为UNIX编写的代码。我试着在cygwin环境中这样做。C++标准从这个时候和标准库也被改变了。

我尝试使用-std=和-traditional cpp选项,但这些选项对我毫无帮助。我还发现作用域的-fno和-fno操作符名称减少了错误的数量。从那时起,输入/输出库也发生了重大变化。我还认为,从那时起,预定义的(由预处理器)宏也可能发生变化

代码的作者注释:

库中的C代码(库/linpack和库/配方)使用以下方法编译:

gcc -c *.c
<> > C++代码更麻烦。../include中有标题,它们要求-DANSI生成函数原型。它们未在标题中声明
extern“C”
;它们在C++源DIR中的标题中被正确包含:

extern "C" {
#include "linpack.h"
}
因此,编译A3dStream.C,我得到:

$ g++ -DANSI -I../include -c A3dStream.C
In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,
                 from Hh.h:12,
                 from A3dStream.C:4:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one deprecated or antiquated header.
Please consider using one of the 32 headers found in section 17.4.1.2 of the C++
standard.    Examples include substituting the <X> header for the <X.h> header for
C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable
this warning use -Wno-deprecated.
In file included from A3dStream.C:4:
Hh.h:15:23: strstream.h: No such file or directory
In file included from A3dStream.C:4:
Hh.h:45: error: declaration of C function `void bzero(void*, int)' conflicts with
/usr/include/string.h:54: error: previous declaration `void bzero(void*, size_t)' here
Hh.h:46: error: declaration of C function `int gethostname(char*, int)' conflicts with
/usr/include/sys/unistd.h:206: error: previous declaration `int gethostname(char*, size_t)' here
Hh.h:98: error: an explicit specialization must be preceded by 'template <>'
Hh.h:105: error: an explicit specialization must be preceded by 'template <>'
Hh.h:111: error: an explicit specialization must be preceded by 'template <>'
Hh.h:221: error: new declaration `void unsetenv(const char*)'
/usr/include/cygwin/stdlib.h:26: error: ambiguates old declaration `int unsetenv(const char*)'
In file included from Geometry.h:10,
                 from A3dStream.h:7,
                 from A3dStream.C:5:
Array.h: In member function `void Array<T>::resize(int)':
Array.h:40: error: `size' undeclared (first use this function)
Array.h:40: error: (Each undeclared identifier is reported only once for each function it appears in.)
Array.h:44: error: `a' undeclared (first use this function)
Array.h: In member function `void Array<T>::clear()':
Array.h:51: error: `a' undeclared (first use this function)
Array.h:51: error: `size' undeclared (first use this function)
Array.h: In member function `void Array<T>::init(int)':
Array.h:53: error: `size' undeclared (first use this function)
Array.h: In member function `void Array<T>::need(int)':
Array.h:57: error: `size' undeclared (first use this function)
Array.h: In member function `Array<T>& Array<T>::operator+=(const T&)':
Array.h:64: error: `a' undeclared (first use this function)
Array.h: In member function `void Array<T>::squeeze()':
Array.h:66: error: `size' undeclared (first use this function)
Array.h: In member function `const T& Array<T>::operator[](int) const':
Array.h:70: error: `a' undeclared (first use this function)
Array.h: In member function `T& Array<T>::operator[](int)':
Array.h:71: error: `a' undeclared (first use this function)
$g++-DANSI-I../include-c A3dStream.c
在/usr/lib/gcc/i686 pc cygwin/3.4.4/include/c++/backward/iostream.h:31中包含的文件中,
从Hh.h:12开始,
来自A3D流。C:4:
/usr/lib/gcc/i686 pc cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2:
警告:#警告此文件至少包含一个已弃用或过时的标头。
请考虑使用C++中的32节中的一个标题
标准示例包括用标题替换标题
C++包含或替代未标示的标头。禁用
此警告不推荐使用-Wno。
在A3dStream.C中包含的文件中:4:
Hh.h:15:23:strstream.h:没有这样的文件或目录
在A3dStream.C中包含的文件中:4:
Hh.h:45:错误:C函数“void bzero(void*,int)”的声明与
/usr/include/string.h:54:错误:前面的声明“void bzero(void*,size_t)”在这里
Hh.h:46:错误:C函数“int gethostname(char*,int)”的声明与
/usr/include/sys/unistd.h:206:错误:前面的声明“intgethostname(char*,size_t)”在这里
Hh.h:98:错误:显式专门化前面必须有“template”
Hh.h:105:错误:显式专门化前面必须有“template”
Hh.h:111:错误:显式专门化前面必须有“template”
Hh.h:221:错误:新声明“void unsetenv(const char*)”
/usr/include/cygwin/stdlib.h:26:错误:对旧声明“int unsetenv(const char*)”进行歧义
在Geometry.h:10中包含的文件中,
来自A3D流。h:7,
来自A3D流。C:5:
Array.h:在成员函数“void Array::resize(int)”中:
Array.h:40:错误:`size'未声明(首先使用此函数)
Array.h:40:error:(每个未声明的标识符对于它出现在其中的每个函数只报告一次。)
Array.h:44:错误:`a'未声明(首先使用此函数)
Array.h:在成员函数“void Array::clear()”中:
Array.h:51:error:'a'未声明(首先使用此函数)
Array.h:51:错误:`size'未声明(首先使用此函数)
Array.h:在成员函数“void Array::init(int)”中:
Array.h:53:错误:`size'未声明(首先使用此函数)
Array.h:在成员函数“void Array::need(int)”中:
Array.h:57:错误:`size'未声明(首先使用此函数)
Array.h:在成员函数“Array&Array::operator+=(const T&)”中:
Array.h:64:错误:`a'未声明(首先使用此函数)
Array.h:在成员函数“void Array::squence()”中:
Array.h:66:错误:`size'未声明(首先使用此函数)
Array.h:在成员函数'const T&Array::operator[](int)const'中:
Array.h:70:错误:`a'未声明(首先使用此函数)
Array.h:在成员函数'T&Array::operator[](int)'中:
Array.h:71:错误:`a'未声明(首先使用此函数)
其他文件会产生类似的错误集

我在WindowsXP下的Cygwin上使用GCC 3.4.4

我不是C++大师——虽然我做了相当数量的软件考古学,但是我觉得你需要更新代码来使用C++标准头,因为特别是STRSOWS.H丢失了(所以,名义上,使用<代码> <代码>),这意味着你必须处理<代码> STD< /Cord>命名空间等。这段代码比标准早了5年,因此必须对其进行严格的修改才能使其更新是合理的


祝你好运

我可以想到两种可能性:AT&T同时提供(可能与Cygwin有足够的不同,以避免相同的麻烦)和的源代码(可能是使用的原始编译器)


嗯,还有第三种可能性,我认为这是建议的措施:编辑源代码并使其符合标准。如果您打算对这段代码进行任何进一步的开发,最好尽早完成。

您仍然可以从GNU网站下载gcc 2.7.0的源代码


您可以下载并制作较旧版本的编译器。

如果您描述了编译此代码时遇到的至少一个错误、您试图更正错误的方法以及结果,可能会对我们有所帮助。