From: waterlan <wat...@xs...> - 2013-01-23 14:21:15
|
Keith Marshall schreef op 2013-01-23 12:57: > On 23 January 2013 11:13, waterlan wrote: >> There are some portability issues. >> * setmode() was depreciated [sic] in Microsoft Visual C 2005, ... > > I think you mean "deprecated"; "depreciated" means something else > entirely :) Yes. Although deprecate can mean depreciate according to http://www.thefreedictionary.com/deprecated I meant obsoleted. English is not my native language. > >> ... so to be compatible with VC you should use _setmode(). > > Why? Deprecated doesn't mean withdrawn; setmode() should continue to > work just fine. Certainly, you may argue the VC compatibility case, > and if this "deprecation" was anything other that part of Microsoft's > campaign toward vendor lock-in, I might agree. However, since POSIX > requires setmode(), and not _setmode(), and since VC is likely to > continue, albeit reluctantly, to support this POSIX standard in > perpetuity, your case seems very insubstantial; certainly, MinGW will > continue to provide -- and prefer -- the POSIX form. > >> ... >> >> This is what I do in dos2unix to be portable across all OSes: >> >> #if defined(_WIN32) && !defined(__CYGWIN__) >> >> /* stdin and stdout are by default text streams. We need >> * to set them to binary mode. Otherwise an LF will >> * automatically be converted to CR-LF on DOS/Windows. >> * Erwin */ >> >> /* 'setmode' was deprecated by MicroSoft >> * since Visual C++ 2005. Use '_setmode' instead. */ >> >> _setmode(fileno(stdout), O_BINARY); >> _setmode(fileno(stdin), O_BINARY); > > Here, you are being grossly inconsistent. If you insist that you > *must* use _setmode(), then you must also insist on _O_BINARY, (for > the same reason); ditto _fileno(), since Microsoft also declared > fileno() to be deprecated, along with setmode(); (I wonder why they > neglected to apply this same asinine philosophy consistently, to > stdin, stdout, and stderr, and even to FILE)? > You are right. -- Erwin Waterlander http://waterlan.home.xs4all.nl/ |