[SDL] Another way to disable stdout redirection

Tim Carlsen snyggdrasil at yahoo.com
Mon Aug 28 03:48:00 PDT 2006


Hi All,

I'm using SDL with MingGW (gcc 3.2.3) under Windows 98
SE.
There's a way to disable stdout redirection that isn't
mentioned in the SDL FAQ for Windows:
http://www.libsdl.org/faq.php?action=listentries&category=4#85

I'm curious if it works for people using other
compilers or operating systems.

<main.c>
  #include "pmain.h"
 
  int main(int argc, char *argv[]) {
    return(pmain(argc, argv));
  }
</main.c>

<pmain.h>
  #ifndef PMAIN_H
  #define PMAIN_H

  int pmain(int argc, char *argv[]);
 
  #endif
</pmain.h>

<pmain.c>
  #include "SDL.h"
  #include "pmain.h"
 
  /* pseudo main function */
  int pmain(int argc, char *argv[]) {
  }
</pmain.c>

Instead of main(), you now use pmain() as your main
function.
This code disables stdout redirection on my system.

How it works:
- if SDL.h is included (either directly or indirectly)
in the source file that contains main(), then stdout
is redirected to stdout.txt (as it should be)
- if SDL.h is not included (neither directly or
indirectly) in the source file that contains main(),
then stdout redirection is disabled

This little trick was discovered by the people working
on Nuvie:
http://nuvie.sf.net

--
Tim Carlsen


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the SDL mailing list