tags:

views:

656

answers:

3

I need to have a windows executable for some code which was written in 1994 for UNIX. I tried to do this from cygwin environment. The C++ standard was changed from this time and the standard libraries too.

I tried to use -std= and -traditional-cpp options, but that options didn't helped me at all. I also found that -fno-for-scope and -fno-operator-names reduced number of errors. Also input/output libraries was changed significantly from that time. I also think that there is some possibility that predefined (by preprocessor) macroses is changed from that time too.

Author's notes on the code:
http://research.microsoft.com/en-us/um/people/hoppe/code.htm

+1  A: 

The C code in library (library/linpack and library/recipes) compiles fine using:

gcc -c *.c

The C++ code is more problematic. There are headers in ../include and they require -DANSI to yield function prototypes. They are not declared extern "C" in the headers; they are included correctly in the headers in the C++ source dir:

extern "C" {
#include "linpack.h"
}

So, compiling A3dStream.C, I get:

$ 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)

Other files yield similar sets of errors.

I'm using GCC 3.4.4 on Cygwin under Windows XP.

I'm not a C++ guru - though I do my fair share of software archaeology - but it looks to me like you are going to need to update the code to use C++ standard headers because strstream.h in particular is missing (so, nominally, use <strstream> instead), and that means you'll have to deal with the std namespace and the like. This code pre-dates the standard by 5 years, so it is not unreasonable to have to hack it hard to bring it up to date.

Good luck!

Jonathan Leffler
A: 

I can think of two possibilities: AT&T offers both UWIN (which may be different enough from Cygwin to avoid the same trouble) and the source for old versions of CFront (which is probably the original compiler used).

Well, there's a third possibility, and I think it's the recommended action: edit the source and bring it up to date to the standard. If you intend to do any further development on this code, it's best to bite the bullet sooner rather than later.

Max Lybbert
A: 

You can still download the source for gcc 2.7.0 from the GNU web site.

You could download and make the older version of the compiler.

James Anderson