Skip to main content
GameDev.net gamedev.net
🔒 Locked

Error stream

Started by TythosEternal May 28, 2003 at 2:20 PM 3 replies 850+ views
Original Post
TythosEternal
TythosEternal
I have a text stream for debugging, outputting to a file, initialized like this:
  
remove("ErrorLog.txt");
        //Removes old version of ErrorLog.txt

g_DebugText.open("ErrorLog.txt", ios::in | ios::out);	//Creates a new text file for read/write

  
Used like this:
  
void SetError(char * String)
{
    g_DebugText << String << endl;
}
  
And closed like this:
  
g_DebugText.close();
  
Normally it works fine, but suddenly, it doesn''t - I haven''t touched it. When I comment out SetError''s only line of code and output text using the << operator instead of a function call, it works. Otherwise, it just shows a blank text file. I am slowly but surely being driven insane by this problem. I''ve been debugging for two straight days, doing nothing else, and have absolutely no idea what''s going on. Help. Please. - TythosEternal PS - The older versions of the same program, with identical lines of code for the stream and the SetError function, work fine. "Who''s John Galt?"
"Who's John Galt?"
drslush
drslush
I didn''t look at your problem closely, but try hitting "Rebuild All". There is a REALLY annoying bug (feature perhaps?) that doesn''t always rebuild all code if you have it set to only compile changed source. I had a similar problem where i touched nothing and it stopped working. It had the most bizzare debug information while I was stepping through the code ;-D

Chances are this isn''t your problem, but its worth a shot.

My Lame Site
krez
krez
is the program crashing? if it is, it might help to flush the log file''s buffer (g_DebugText.flush()) after every write. this will slow it down a bit, but if the app stops before the close() at least you won''t lose stuff that was buffered but not written yet.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
TythosEternal
TythosEternal
Tried the rebuild thing. If it worked, I would have puked out of sheer annoyance. I''m afraid it didn''t...

The program isn''t crashing, either. It runs fine - but something about that function is somehow clearing the stream, or preventing it from closing properly (now there''s a thought...). Of course, there''s only a SINGLE FRIGGIN'' LINE OF CODE, and goodness knows there''s not a lot wrong with it.

- TythosEternal




"Who''s John Galt?"
"Who's John Galt?"
original vesoljc
original vesoljc
i had a similar problem once with reading/writing fstream''s.
didnt work if i wanted to read&write from one stream...

try only ios:out when u create stream.
Abnormal behavior of abnormal brain makes me normal...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.