[SDL] Re: I/O problem solvable.... need Help though.

Benjamin Deutsch ben at fictiongroup.de
Sat Jan 22 00:41:54 PST 2005

>>This is the third time this problem (no clean way to get rid of stdio 
>>redirect) has been brought up [...]  it's really just waiting
>>for someone to step up and write a patch to SDL.
> I hope said patch completely removes the feature. Any app that
> needs this feature can simply add:
> freopen("stdin.txt", "r", stdin);
> freopen("stdout.txt", "a", stdout);
> freopen("stderr.txt", "a", stderr);

I see two problems with this (we might as well discuss this now, instead 
of at patching time):

1) Most apps on Windows need this feature, since Windows has no easily 
accessible standard IO otherwise. Therefore, it makes sense to have 
redirection enabled by default.

2) Backwards compatibility. An unchanged app from before the patch 
should behave the same.

The best solution that I can see, given the two assumptions above, is to 
add a function SDL_RedirectStdIO(int flag), which can be used to turn 
the redirection on or off, and have it *on* by default.

While we're at it, let's add another state (on, off, auto), where 'auto' 
behaves like originally (i.e. platform dependant), and 'on' and 'off' 
force redirection on or off regardless of platform. This way the call 
actually "adds value" ;-)

(Optionally, a way to change the filenames, or specify only partial 
redirection. This may be easier on the command line or application 

Am I correct in assuming, though, that such a function would have to be 
called *before* SDL_Init ? That might make things a bit awkward.

   Benjamin Deutsch

More information about the SDL mailing list