redirecting debug output to a file on Windows

Linus Torvalds torvalds at linux-foundation.org
Thu Feb 2 16:22:23 PST 2017


On Thu, Feb 2, 2017 at 2:46 PM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> *stderr = *stdout; // seems safe

Don't. It's definitely not safe. It quite likely doesn't even compile
in a number of situations, since there is nothing to keep people from
using an opaque type for the stdio "FILE" type. In fact, that's more
commonly the case than not.

So it might work. Or it might compile and not work. Or it might not
even compile.

You're likely better off using two different files.

Or try the "freopen()" thing to the same file, but use "a" (append) as
the mode (and make both stdout and stderr be line buffered, or
unbuffered).

                Linus


More information about the subsurface mailing list