This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

building (porting) c++ project w/ deprecated features -- did I do this right?


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]