Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL and stdout?

Started by martin_bfg10k Jul 31, 2007 at 10:17 PM 4 replies 1.1k views
Original Post
martin_bfg10k
martin_bfg10k
Is there a way to output with stdout in the console, rather than stdout.txt? Could that be posible without recompiling SDL? In linux it outputs in the console, but not in windows. Thanks.
speciesUnknown
speciesUnknown
OK, this is what a gathered while I used to make stuff for windows:

Console applications print to the console.
win32 applications create an stdout.txt

The reason for this is that stdio requires a console of some kind to work, and the windows api substitutes stdout.txt, to ensure compatibility I think. Either way, it uses a text file as the console.

So, you need to compile your application as a console application from the ground up.

If your main function is
int WINAPI
WinMain(HINSTANCE hInst,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)

Then you have a win32 application, which will use stdout.txt as the console.
alternatively, if you have int main() or int main(char ** argc, int argv) or just int main() then you have a console application and stdout should use the console.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
martin_bfg10k
martin_bfg10k
Well, sorry for this noob question :(
With sdl, int main( int argc, char* argv[]) is the main function, so it should be a console aplication, but maybe sdl redefines it to a WinMain funtion?
let_bound
let_bound
Quote:
Original post by martin_bfg10k
Well, sorry for this noob question :(
With sdl, int main( int argc, char* argv[]) is the main function, so it should be a console aplication, but maybe sdl redefines it to a WinMain funtion?


SDL defines main to SDL_main in SDL_main.h. On Windows, it supplies its own WinMain in the SDLmain.lib file (IIRC).

There is AFAIK no way to disable redirection without recompiling SDL. If you don't mind recompiling it, I think there is a --disable-stdio-redirect flag to pass to configure (./configure --help will give you a list of options) . I don't know how to do that with Visual Studio because I don't use it.
martin_bfg10k
martin_bfg10k
It seems that I will have to recompile sdl for windows.
Thanks for the replies.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.