delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/12/20:22:33

Date: Wed, 12 Nov 1997 17:20:41 -0800 (PST)
Message-Id: <199711130120.RAA04303@adit.ap.net>
Mime-Version: 1.0
To: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: problem with fstream it erases my input file !

At 11:52  11/12/1997 +0100, Thomas Demmer wrote:
>Marius wrote:
>[...]
>> #include <fstream.h>
>> 
>> int main(int argc, char *argv[])
>> {
>>     fstream                         // open the file to read and write
>>         stream(argv[1],ios::in | ios::out);
>> }
>> 
>> My C++ teacher executed this code with GNU C++ on linux and it worked
>> fine.
>> However when I run it (on DOS DJGPP GNU C++) it empties my argument
>> file.
>> 
>> Has anyone using DJGPP had the same problem, if so some help would be
>> nice because I don't know what's wrong.
>AFAIK this is a bug in libiostream. The workaround is to use
>open() to open the file in the desired mode and
>then feed the handle into the constructor. 
>
>Unless anybody dares to fix the lib, this bug will persist.
ISTR a flag called "nodelete" that made this work properly. But maybe the
bug was with it...

Nate Eldredge
eldredge AT ap DOT net



foo");

`foo' becomes a symbol like the assembly you're used to, except that its
address is 32 bits. Note that inline asm syntax is different, see FAQ
section 18.13 for more info.

If you really want the linear address, you can do something like:
__dpmi_get_segment_base_address(_my_ds())
and add that to the offset (virtual address) of the variable (&foo). But
note that the segment base can change without warning. I think there is also
a DPMI function to get the physical address too, if you need it, but virtual
memory paging can screw this up.

HTH

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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