In my game I have a global ofstream instance called Log which I write to for various debugging info. I''ve used this setup in multiple projects and it has worked fine. In fact, the current project is using the exact same code from my last project simply copied over as a starting point. But for some weird reason, it''s causing unhandled exception errors in this project.
That in itself wouldn''t be too weird, it''s the fact that the program will happily write one or two lines to the file then decides it no longer exists (or watever it has decided is wrong) and throw exceptions.
I ditched the new project and started agin, copying the files from a third project which also works fine. Again, the same error occurs. It only occurs in my current project, not in any of the other completed/abandoned projects.
When the debugger stops the exception it shows this code form the ostream.cpp file:
int ostream::opfx()
{
lock();
if (state)
{
state |= ios::failbit;
unlock();
return 0;
}
if (x_tie)
{
x_tie->flush();
}
lockbuf();
return(1); // return non-zero
}
saying that the error is on the first line (call to lock). The code I am using to open and write tot he files is the most basic code possible which I have used hundreds of times before. I simply use:
ofstream Log;
Log.open("filename.log", ios::out);
...
Log<<"yadda yadda";
But somehow this is dying. I checked the file and it has access permissions. I even deleted it so it would be remade. I''m at a complete loss as to what might be causing this.