X-Spam-Check-By: sourceware.org From: ericblake AT comcast DOT net (Eric Blake) To: Nate Thern , cygwin AT cygwin DOT com Subject: Re: building (porting) c++ project w/ deprecated features -- did I do this right? Date: Tue, 04 Apr 2006 02:52:00 +0000 Message-Id: <040420060252.19335.4431DF500009BCA400004B8722007358340A050E040D0C079D0A@comcast.net> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 had to do the following to get it to compile: > 1) add a "strstream.h" in the headers directory that includes Are you adding files to /usr/include? That is asking for problems. You are better off teaching your application about modern C++, and sending those patches back upstream to the "C Scripting Language" project. > 2) force headers to define UNIX because cygwin was treated as equivalent to > win32 That is also a no-no. Cygwin compiles define __CYGWIN__. But more importantly, keying off of UNIX being defined is very non-portable and too broad; you are better off following the autoconf philosophy of testing every fine-grained feature you will be using to see if that particular feature is present on the current platform, rather than resorting to platform-specific #defines. > 3) change all istrstream calls to std::istrstream Or you could also add 'using namespace std;'. > 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 Huh? And linking against .o instead of .so bloats the final image size, if you really intend to dynamically load the .so files. > 5) "the biggie" - change a function that opens files as follows > > switch (mode) { > case 1: { mode2 = std::_S_in; } Evil. Use symbolic constants, not magic numbers in your cases. And you forgot break statements, as well as whether multiple bits can be set in mode, so no matter what mode is, you are setting mode2 to std::_S_ios_openmode_end. Also, names with leading underscore and capital letters (such as _S_out) are reserved for the library; your code should never need to refer to them. > 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? > -- Eric Blake -- 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/