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]

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


> I had to do the following to get it to compile:
> 1) add a "strstream.h" in the headers directory that includes <strstream>

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/


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