I have worked on embedded systems where one of the most common errors during development was out of memory. We were able to use a streaming interface for error logging by using macros that expanded to something along the lines of:

extern char error_buffer[500];

if (error) {
  ostrstream os(error_buffer, sizeof(error_buffer));
  os << "Error message" << ends;
  error_handler(error_buffer, __FILE__, __LINE__);
}


-----Original Message-----
From: David Abrahams [mailto:david.abrahams@rcn.com]
Sent: Wednesday, November 14, 2001 9:24 AM
To: boost@yahoogroups.com
Subject: Re: [boost] Re: Boost.Assert


From: "Ullrich Koethe" <u.koethe@computer.org>

> > My 2 cents: I worry a little about any error detection mechanism that
> > requires the allocation of resources. In particular, this streaming
> > interface looks on the surface like it could throw an exception before
the
> > intended error is reported.
> >
>
> You are right, but any decent error reporting scheme will require
> allocation of some ressources. It's a tradeoff between convenience and
> safety, and I would probably vote on the convenience side.

I'm not certain: isn't it possible to used some kind of fixed-size buffer
for this? I'd be content if the resources only needed to be allocated once,
at startup.




Info: http://www.boost.org  Unsubscribe: <mailto:boost-unsubscribe@yahoogroups.com>

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/