[Development] Cake and eating it too for qDebug printing to system log - https://codereview.qt-project.org/89357
Oswald Buddenhagen
oswald.buddenhagen at digia.com
Thu Jul 10 19:34:59 CEST 2014
On Thu, Jul 10, 2014 at 10:17:52AM -0700, Thiago Macieira wrote:
> On Thursday 10 July 2014 16:50:22 Shawn Rutledge wrote:
> > On Windows I never liked CONFIG += console, because it's never in the
> > .pro by default (usually not in manual tests or examples, and not in
> > Creator-generated pro files either) and yet I would like to always
> > have qDebug output in the console when the app is running in a
> > console. So detecting whether the app is running in a console and
> > automatically sending debug output there would mean that we no longer
> > need that flag in the .pro, right? If it's technically possible, we
> > should have done that years ago.
>
> I don't think it's possible at all. If the application was compiled to the GUI
> subsystem, it *has* no stdout and stderr. We can open a new console window,
> but I don't think you can write to an existing one.
>
"windows is stupid, but it can't be that stupid, can it?" => google =>
AttachConsole(ATTACH_PARENT_PROCESS)
GetStdHandle(STD_ERROR_HANDLE)
(and _open_osfhandle(h) if one cares for stdio)
More information about the Development
mailing list