delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/04/03/22:30:25

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Nate Thern <nthern AT yahoo DOT com>
Subject: building (porting) c++ project w/ deprecated features -- did I do this right?
Date: Mon, 3 Apr 2006 21:13:51 +0000 (UTC)
Lines: 48
Message-ID: <loom.20060331T184720-927@post.gmane.org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

I'm building "The C Scripting language" on cygwin, and it uses some deprecated 
c++ include files and notations. The ones that caused problems are fstream.h 
and strstream.h

I had to do the following to get it to compile:
1) add a "strstream.h" in the headers directory that includes <strstream>
2) force headers to define UNIX because cygwin was treated as equivalent to 
win32
3) change all istrstream calls to std::istrstream
4) Each new .so library created linked to a previous .so that had function 
names which were duplicated in the new .o files. I solved this by changing the 
makefiles to link instead to the .o files that created the previous .so
5) "the biggie" - change a function that opens files as follows

-----ORIG: ---------
static ZString fileOpen(ZCsl* csl)
{
   ZString fname = csl->get("filename");
   int     mode  = csl->get("mode").asInt();
   iostream* str = new fstream(fname.constBuffer(), mode);
   ...
}
------ MODIFIED: --------
static ZString fileOpen(ZCsl* csl)
{
   ZString fname = csl->get("filename");
   int     mode  = csl->get("mode").asInt();
   std::_Ios_Openmode mode2;
   switch (mode) {
   case 1: { mode2 = std::_S_in; }
   case 2: { mode2 = std::_S_out; }
   case 4: { mode2 = std::_S_ate; }
   case 8: { mode2 = std::_S_app; }
   case 16: { mode2 = std::_S_trunc; }
   case 128: { mode2 = std::_S_bin; }
   default: { mode2 = std::_S_ios_openmode_end; }
   }
   iostream* str = new fstream(fname.constBuffer(), mode2);
   ...
}

6) I also deleted all references to ios::nocreate and ios::noreplace in the 
same file.

It compiles fine, but complains that it can't initialize when I try to run 
the 'hello' example. Can anyone see something obvious?




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019