|
From: Daniel J S. <dan...@ie...> - 2017-03-30 17:01:37
|
On 03/30/2017 08:02 AM, Hans-Bernhard Bröker wrote:
> Am 29.03.2017 um 21:01 schrieb Daniel J Sebald:
>> On my system, configuration results in the unused return variable flag
>> being set. Attached is a diff file with code changes to get rid of
>> those warnings.
>
> Doing the change like that is just wrong:
>
>> - freopen("/dev/null","w",stdout);
>> - freopen("/dev/null","w",stderr);
>> + if (freopen("/dev/null","w",stdout));
>> + if (freopen("/dev/null","w",stderr));
>
> The usual, widely accepted way of doing that is to cast an unused return
> value to (void), i.e.:
>
> (void)freopen("/dev/null","w",stdout);
> (void)freopen("/dev/null","w",stderr);
That was my initial thought, but I had read on a couple discussion lists
that void-cast doesn't work for some compilers any more.
>> Should the above really be included in Qt? I don't think that Qt C++
>> files need to use FPRINTF() any more for debugging.
>
> That doesn't help with debugging non-QT, non-C++ files in gnuplot at
> all, though.
>
>> Qt has it's own
>> messaging system:
>
> That's nice to know, but doesn't help us much, because we still want to
> be able to work _without_ any Qt involved, too.
The Qt terminal is a separate compilation and process. I tried Ethan's
idea of simply closing stderr and stdout rather than reopening. (fclose
doesn't return anything, so no warning.) I can't see any difference in
behavior of persist mode. I see a comment online about someone trying
to redirect std::cerr and std::cout, so I would guess they are separate
entities:
http://qtforum.org/article/678/redirecting-cout-cerr-to-qdebug.html
Dan
|