Code::Blocks Forums

User forums => Help => Topic started by: Fero on April 23, 2006, 05:03:19 am

Title: SDL + console
Post by: Fero 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.
Title: Re: SDL + console
Post by: Zingam 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
Title: Re: SDL + console
Post by: Fero 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.
Title: Re: SDL + console
Post by: thomas 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).
Title: Re: SDL + console
Post by: Fero 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.
Title: Re: SDL + console
Post by: thomas 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 :)
Title: Re: SDL + console
Post by: Fero on April 24, 2006, 11:34:17 am
thanks a lot!
Title: Re: SDL + console
Post by: takeshimiya 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 );