delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/26/14:01:21

From: pavenis AT lanet DOT lv
To: "Tim 'Zastai' Van Holder" <zastai AT hotmail DOT com>, djgpp AT delorie DOT com
Date: Sat, 26 Aug 2000 19:59:29 +0200
MIME-Version: 1.0
Subject: Re: binary I/O bug ?
Message-ID: <39A821A1.25651.2560B9@localhost>
In-reply-to: <35ep5.27500$Ee.200783@afrodite.telenet-ops.be>
X-mailer: Pegasus Mail for Win32 (v3.12c)
X-MIME-Autoconverted: from Quoted-printable to 8bit by delorie.com id NAA16268
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 24 Aug 2000, at 18:47, Tim 'Zastai' Van Holder wrote:

> "Rafał Maj" <r_maj AT poczta DOT onet DOT pl> wrote in message
> news:8o1930$36j$1 AT info DOT cyf-kr DOT edu DOT pl...
> > I think ther is bug in I/O binary mode :
> >
> > 1)
> > I can't open ofstream / ifstream in ios::binary mode.
> > When I use :
> >   ifstream plik;  plik.open("test.txt",ios::binary); plik<<"OK ;)";
> > plik.close();
> > then test.txt is empty. When I don't use ios::binary, then everything is
> OK.
> No, that means there's a bug in non-binary mode: You're using an input
> stream
> for output. Try using 'ofstream plik;' instead. You may also want to
> explicitly
> mention that you're doing output (ie use 'ios::binary | ios::out' as arg to
> open()).

'ofstream  foo ("foo", ios::binary)'  with gcc-2.95.2 is equivalent to 
'fstream foo("foo", ios::binary)' so file will be opened for both input 
and output. Currently one can use    
	ios::binary | ios::out   
to workaround the problem.

As I said it's fixed in current CVS version of gcc-2.95 branch (ios::out
is added unconditionally, and similary ios::in for ifstream). I put this
patch in in my last build of gcc-2.95.2 in end of March. But binaries are 
not uploaded to ftp.delorie.com. This will go in if gcc-2.95.3 will be 
realesaed sometimes, but don't ask me when (and whether) it will 
happen.

Andris

- Raw text -


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