[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Catching exceptions thrown in OnInit()
From: |
Greg Chicares |
Subject: |
Re: [lmi] Catching exceptions thrown in OnInit() |
Date: |
Thu, 29 Jun 2006 02:41:11 +0000 |
User-agent: |
Thunderbird 1.5.0.4 (Windows/20060516) |
On 2006-6-28 20:12 UTC, Greg Chicares wrote:
> On 2006-6-28 19:13 UTC, Vadim Zeitlin wrote:
>> On Wed, 28 Jun 2006 19:00:26 +0000 Greg Chicares <address@hidden> wrote:
> [...]
>> GC> void safe_message_alert(char const* message)
>> GC> {
>> GC> #if !defined LMI_MSW
>> GC> std::fputs(message, stderr);
>> GC> std::fputc('\n', stderr);
>> GC> // Flush explicitly. C99 7.19.3/7 says only that stderr is
>> GC> // "not fully buffered", not that it is 'unbuffered'. See:
>> GC> // http://sourceforge.net/mailarchive/message.php?msg_id=10388832
>> GC> // http://sourceforge.net/mailarchive/message.php?msg_id=10826040
>> GC> std::fflush(stderr);
>> GC> #else // defined LMI_MSW
>>
>> Interesting. I can't access these links right now ("We're Sorry. The
>> SourceForge.net Website is currently down for maintenance. We will be back
>> shortly") but I thought that "not fully buffered" means either "unbuffered"
>> or "line buffered" (i.e. flushed on newline) so this fflush() seems to be
>> unnecessary. OTOH it surely does no harm.
>
> I think I remember what they say. This is a recurring MinGW problem
> report. Some people expect anything written to stderr to appear
> immediately and unconditionally, even in a case like
> cerr << "Some message with no newline";
> abort();
> or
> cerr << "Some message with no newline";
> code_that_causes_a_segfault();
> Probably one of those links shows the gcc msw maintainer explaining
> that such a hope goes beyond what the C or C++ standard requires.
Sourceforge is temporarily available again, and I see that Danny's point was
more subtle: standard streams can be redirected, too. I guess that's why
C99 7.19.3/7 imposes some of its requirements only "...if the stream can be
determined not to refer to an interactive device." And he adds: "That's what
other code does. Eg, grep gcc source tree for fflush (stderr)."