Stdout and stderr redirection question

Very strange question, hopefully someone can explain this to me:

I have a singleton class whose constructor is called before main (a
global object, essentially). If I put a cout or cerr statement in the
constructor, the stdout.txt and stderr.txt files, whichever I write
to, don’t get created. If I leave those statements out of the
constructor, or comment them out, the txt files show up and are filled
with my debug statements. Everything else works fine either way.

Is there a simple answer why this happens?

Thanks,

-Justin

simply because SDLmain hasn’t redirected to files yet since it hasn’t been called.
writing to stdout/stderr before that redirect happens, makes the output go nowhere, until SDLmain runs through.

that’s what I think anyways.

-LIM-

Justin Coleman wrote:> Very strange question, hopefully someone can explain this to me:

I have a singleton class whose constructor is called before main (a
global object, essentially). If I put a cout or cerr statement in the
constructor, the stdout.txt and stderr.txt files, whichever I write
to, don’t get created. If I leave those statements out of the
constructor, or comment them out, the txt files show up and are filled
with my debug statements. Everything else works fine either way.

Is there a simple answer why this happens?

Thanks,

-Justin


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I had the same problem. I tried on MSVC++ 6, MSVC.net, and KDevelope. It
worked on KDevelope but not on the MSVC versions. Also, make sure your
program is calling exit (ie. setting up esc to exit) and you are not just
closing the window.

-Steven

Very strange question, hopefully someone can explain this to me:

I have a singleton class whose constructor is called before main (a
global object, essentially). If I put a cout or cerr statement in the
constructor, the stdout.txt and stderr.txt files, whichever I write
to, don’t get created. If I leave those statements out of the
constructor, or comment them out, the txt files show up and are filled
with my debug statements. Everything else works fine either way.

Is there a simple answer why this happens?

Thanks,

-Justin_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

how about a link to the source code?

Paul Lowe
pauls_lists at tetravista.netOn Friday 22 October 2004 06:17 pm, Justin Coleman wrote:

Very strange question, hopefully someone can explain this
to me:

I have a singleton class whose constructor is called
before main (a global object, essentially). If I put a
cout or cerr statement in the constructor, the stdout.txt
and stderr.txt files, whichever I write to, don’t get
created. If I leave those statements out of the
constructor, or comment them out, the txt files show up
and are filled with my debug statements. Everything else
works fine either way.

Is there a simple answer why this happens?

Thanks,

-Justin


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl