could you change that easily ?
No, because it's not a bug but a feature. If you look into it, only the debug target is set to be a console project. This is on purpose as many debug information you issue within a GUI application are actually send to the console. This is a usual concept (have a look at several debug macros) and if you declare the debug target as GUI application you would not see the messages printed to the console.
So we won't chnage this because it's by design. Anyway, if you don't like this feature you can disable it in the wizard script easily. Just right-click on the script, edit it and change the debug target creation to how it's done in the release target:
Change the line:
target.SetTargetType(ttConsoleOnly); // ttConsoleOnly: console for debugging
into:
target.SetTargetType(ttExecutable); // ttExecutable: no console
With regards, Morten.
A solution to redirect output to the console in Windows is:
- For example in SDL, which by default redirects to a file, just add this below main():
freopen("CON", "wt", stdout); // redirects stdout
freopen("CON", "wt", stderr); // redirects stderr
- In Win32 GUI, if you want to open and close the console dinamycally:
http://lua-users.org/lists/lua-l/1999-08/msg00001.html
i saw some code for this in the past somewhere, but i can't find it at the moment ... i have to look for again.
void CodeBlocksApp::InitDebugConsole()
{
#ifdef __WXMSW__
#ifdef __CBDEBUG__
// Remember to compile as a console application!
AllocConsole();
HANDLE myhandle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD co = {80,2000};
SetConsoleScreenBufferSize(myhandle, co);
fprintf(stdout,"CONSOLE DEBUG ACTIVATED\n");
// wxLogWindow *myerr = new wxLogWindow(NULL,"debug");
#endif
#endif
}
ok i've found the solution in order to give Win32-GUI-apps a linux-like behaviour ( but it needs at least WinXP )
with AttachConsole()
AttachConsole(ATTACH_PARENT_PROCESS);
freopen("CON", "wt", stdout); // redirects stdout
you can attach the GUI app to an existing console window, if there exists one,
with other words, if it was started from the commandline from a console window.
attached is a sample project which demonstrates this
run the Release build from a console window and enjoy the debug messages :D
the code which i can't find anymore did that AttachConsole-stuff also for older Windozes like Win98, ME, NT etc...
if you use MinGW-win32api-3.7 the headers already contain the needed defines,
otherwise i've added them to the code and you need to enable them.
[attachment deleted by admin]