www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/27/02:15:52

From: "Tom Demmer" <DEMMER AT brain1 DOT lstm DOT ruhr-uni-bochum DOT de>
Organization: Lehrstuhl Stroemungsmechanik, RUB
To: Andy Maddison <maddison AT coventry DOT ac DOT uk>, djgpp AT delorie DOT com
Date: Thu, 27 Nov 1997 08:14:24 GMT-1
Subject: Re: Please Help! - file i/o
Reply-to: Demmer AT LStM DOT Ruhr-Uni-Bochum DOT De
Message-ID: <A20EAC24986@brain1.lstm.ruhr-uni-bochum.de>

> Can anyone help me?
> 
> Program Fragment:  
> 
> unsigned char palette[768];  
> fstream inFile; 
> inFile.open("pal.dat",ios::binary);  
> inFile.seekg(0); //not essential
> inFile.read(palette,768);  
> inFile.close();  
> 
> This works fine using Borland C++, but under DJGPP the array (palette) is 
> always filled with zeros (NULLs?).  
> What is happening? Why doesn't it work?  
> I like using C++ and I don't want to have to switch to C style file i/o.
> 
Looks like you stumbled  over a damn bug in libiostream.
It opens the file in write mode, thus truncating it to length 0. 
The workaround is to say something like
 int fd = open("pal.dat",O_RDWR|O_BINARY);
 infile.open(fd);
 
Some comments on this bug:
I have answered this by now at least 3 times in the last two months, 
does this qualify for a FAQ ;-)

Seriously: Who ported libiostream to DJGPP? Not to blame him/her, just
to get an idea how much work that is. 
And, anybody working on that?

Ciao
Tom

  ******************************************************************
  *  Thomas Demmer                     * Phone : +49 234 700 6434  *
  *  Universitaetsstr. 150             * Fax   : +49 234 709 4162  *
  *  Lehrstuhl fuer Stroemungsmechanik *                           *
  *  D-44780 Bochum                    *                           *
  ******************************************************************
  *  Email: demmer AT LStM DOT Ruhr-Uni-Bochum DOT De                         *
  *  WWW:   http://www.lstm.ruhr-uni-bochum.de/~demmer             *
  ******************************************************************

    The amount of intelligence on this planet is constant.
    The population is increasing.

- Raw text -


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