This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: iostream buffer flushing and unitbuf
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "Ian S. Worthington" <ianworthington at usa dot net>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Tue, 1 Feb 2011 00:30:45 +0000
- Subject: Re: iostream buffer flushing and unitbuf
- References: <016PaEXtz1552S02.1296517611@web02.cms.usa.net>
On 31 January 2011 23:46, Ian S. Worthington wrote:
> Hi --
>
> We're using the gnu iostream library under z/tpf.
>
> Multiline output messages to cout are being prefixed with a z/tpf header in
> such a way as to make us suspect that each \n is generating a flush.
>
> I have tried setting nounitbuf without effect.
>
> When I look through the iostream code I find a number of places which set the
> unitbuf flag but very few places which actually interrogate it.
>
> Could someone point me to where this flag is being used to control buffer
> flushing?
It's done by the sentry::~sentry destructor, defined in <ostream>
But that should operate on units of "an output operation" which are
not related to occurrences of \n
e.g. this is a single output operation:
std::cout << "foo\nbar\n";
It sounds more like something affected by the fact the stdout stream
is line-buffered when attached to a terminal, which would be
controlled by something below the level of C++ iostreams.