* Lars Gullik Bjønnes <[EMAIL PROTECTED]> [010307 16:28]:
> John Levon <[EMAIL PROTECTED]> writes:
> 
> | On 7 Mar 2001, Lars Gullik Bjønnes wrote:
> | 
> | > Baruch Even <[EMAIL PROTECTED]> writes:
> | > 
> | > | Hello,
> | > | 
> | > | I believe we should add a printing to the Assert definition so that it
> | > | will be obvious when a core dump is caused by some assert, it would be
> | > | great if it included the line and file of the assert, and it would be
> | > | best if it printed the assert condition itself, but I do not know how to
> | > | achieve that in C++.
> | > | 
> | > | Should I provide a patch for this?
> | > 
> | > then you have to use a macro.
> | 
> | I don't see the harm in such a macro in thise small case, at much greater
> | convenience ...
> 
> #define LYX_ASSERT(x) Assert(x, __FILE__, __LINE__)
> 
> template<class A>
> inline
> void Assert(A assertion, char const * fil, char const * lin)
> {
>         if (!assertion) {
>                 cerr << "Assertion in " << fil << "at line " << lin << endl; 
>                 ::emergencySave();
>                 lyx::abort();
>         }
> }               
> 
> 
> perhaps.
> 
> I am not sure if I like it.

What about a simple;
cerr << "Assertion failed, quitting.\n" << endl;

This will provide the needed info that the exit is from an assert
without going through the hoops of using a macro to provide the line and
file.

-- 
Baruch Even
http://baruch.ev-en.org/

Reply via email to