Author Topic: SDL + console  (Read 5246 times)

Fero

  • Guest
SDL + console
« on: April 23, 2006, 05:03:19 am »
hello. please reveal me, how can i make console SDL application using c::b ? console application is searching for winmain. how can i override it with sdl main? thanks a lot.

Offline Zingam

  • Multiple posting newcomer
  • *
  • Posts: 74
Re: SDL + console
« Reply #1 on: April 23, 2006, 04:23:23 pm »
there is a template and last time I've used it it has done the job for me

Fero

  • Guest
Re: SDL + console
« Reply #2 on: April 23, 2006, 05:25:04 pm »
yes, but template is not console app. i wish to understand, how things work. how can i set-up console app + sdl in c::b ? thanks.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SDL + console
« Reply #3 on: April 23, 2006, 08:18:49 pm »
Right-click on the project, select "Properties", and in the "Targets" tab, select "Console Application" for the value "Type" (top right corner).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Fero

  • Guest
Re: SDL + console
« Reply #4 on: April 23, 2006, 11:53:41 pm »
thanks, ive done it before. but when i printf something to stdout, it writes to file (stdout.txt) instead of console.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: SDL + console
« Reply #5 on: April 24, 2006, 12:16:06 am »
Ah yes, I forgot about that... my bad.

This is a SDL feature, I don't know how to turn it off right now, but it is documented somewhere. I think you have to change only one #define and recompile or something...

EDIT:
There it is: rebuild with NO_STDIO_REDIRECT defined when compiling src/main/SDL_main.c :)
« Last Edit: April 24, 2006, 12:18:50 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Fero

  • Guest
Re: SDL + console
« Reply #6 on: April 24, 2006, 11:34:17 am »
thanks a lot!

takeshimiya

  • Guest
Re: SDL + console
« Reply #7 on: April 24, 2006, 12:57:54 pm »
Fero: alternatively, if you don't want to rebuild SDL, put this at the very beggining of main():

Code: cpp
freopen( "CON", "wt", stdout );
freopen( "CON", "wt", stderr );