From: Tor L. <tm...@ik...> - 2009-05-24 09:09:22
|
> Is there any method to let the printf output *redirect* to GDB console? There are two ways: - Change your executable into a console executable. Either relink it without the -mwindows switch or run some suitable tool on the .exe file that changes the header field in question. (Yes, it is just a single header field that says whether an .exe is "console" or "gui".) The only such tool I know off-hand is editbin.exe (part of MSVC, presumably also present in the no-cost "express" edition), but as such it is a relatively trivial task and would require not much code at all. - Add code to attach the parent process console: AttachConsole(ATTACH_PARENT_PROCESS). After this you probably need to do freopen("CONOUT$", "w", stdout). (I am too lazy to actually test right now.) And you probably should first check if stdout currently actually is attached to an invalid handle before redirecting it with freopen, so that your program won't keep printing to the console even if run with stdout redirected with ">" or a pipe. --tml |