Changeset 2150:cce8ac91c08c in lemon-0.x
- Timestamp:
- 07/18/06 14:10:52 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2864
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/error.h
r1956 r2150 518 518 519 519 template <> 520 inline void assert_fail<const char *>(const char *file, int line, const char *func, 521 const char *message, 522 const char *assertion, 523 bool do_abort) 520 inline void assert_fail<const char *>(const char *file, int line, 521 const char *func, 522 const char *message, 523 const char *assertion, 524 bool do_abort) 524 525 { 525 526 using namespace std; … … 580 581 #undef LEMON_FIXME 581 582 582 #ifndef LEMON_ASSERT_ABORT 583 # define LEMON_ASSERT_ABORT 1 583 #ifdef LEMON_ENABLE_ASSERTS 584 # define LEMON_ASSERT_ABORT 585 #endif 586 587 #ifndef LEMON_ASSERT_DO_ABORT 588 # define LEMON_ASSERT_DO_ABORT 1 584 589 #endif 585 590 … … 589 594 # elif defined LEMON_ASSERT_FAILURE 590 595 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_failure 596 # elif defined LEMON_ASSERT_ABORT 597 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail 591 598 # else 592 # define LEMON_ ASSERT_HANDLER ::lemon::assert_fail599 # define LEMON_DISABLE_ASSERTS 593 600 # endif 594 601 #endif 595 602 596 #if defined(NDEBUG) || defined(LEMON_DISABLE_ASSERTS) 597 598 # define LEMON_ASSERT(exp, msg) (static_cast<void> (0)) 599 600 #else 601 602 /** 603 * \brief Macro for assertions with customizable message 604 * 605 * Macro for assertions with customizable message. 606 * 607 * The behaviour can be customized with LEMON_ASSERT_HANDLER, 608 * LEMON_ASSERT_EXCEPTION and LEMON_ASSERT_ABORT defines. Asserts can be 609 * disabled by defining either NDEBUG or LEMON_DISABLE_ASSERTS macros. 610 * 611 * \todo We should provide some way to reset to the default behaviour, 612 * shouldn't we? 613 * 614 * \todo This whole 'assert' business should be placed in a separate 615 * include file. The boost assert is not guarded by header sentries 616 * which may help to change the behaviour of the assertions in 617 * the files. 618 * 619 * \todo __PRETTY_FUNCTION__ should be replaced by something 620 * compiler-independent, like BOOST_CURRENT_FUNCTION 621 */ 603 #ifdef DOXYGEN 604 605 /// \brief Macro for assertions with customizable message 606 /// 607 /// Macro for assertions with customizable message. 608 /// 609 /// The assertions are disabled in the default behaviour. You can 610 /// enable the assertions with the LEMON_ENABLE_ASSERTS macro what 611 /// provides a log on the standard error about the assertion and aborts 612 /// the program. If the LEMON_ASSERT_DO_ABORT macro is setted to false 613 /// then the just the log message can be seen on the standard error but 614 /// the program is not stopped. With the LEMON_ASSERT_FAILURE and 615 /// LEMON_ASSERT_EXCEPTION macros you can set other behaviour to the 616 /// assertions. The LEMON_ASSERT_FAILURE will always throw an \c 617 /// AssertionFailedError exception with the \c msg error message. The 618 /// \c LEMON_ASSERT_EXCEPTION can throw a user defined exception. 619 /// 620 /// The LEMON_ASSERT macro should be called with the \c exp parameter 621 /// which should be an expression convertible to bool. If the given 622 /// parameter is false the assertion is raised and one of the assertion 623 /// behaviour will be activated. The \c msg should be either a const 624 /// char* message or an exception. When the \c msg is an exception the 625 /// \ref "Exception::what" what() function is called to retrieve and 626 /// display the error message. 627 /// 628 /// 629 /// \todo We should provide some way to reset to the default behaviour, 630 /// shouldn't we? 631 /// 632 /// \todo This whole 'assert' business should be placed in a separate 633 /// include file. The boost assert is not guarded by header sentries 634 /// which may help to change the behaviour of the assertions in 635 /// the files. 636 /// 637 /// \todo __PRETTY_FUNCTION__ should be replaced by something 638 /// compiler-independent, like BOOST_CURRENT_FUNCTION 622 639 623 640 # define LEMON_ASSERT(exp, msg) \ … … 625 642 LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ 626 643 __PRETTY_FUNCTION__, \ 627 msg, #exp, LEMON_ASSERT_ABORT), 0))) 628 629 #endif // NDEBUG || LEMON_DISABLE_ASSERTS 644 msg, #exp, LEMON_ASSERT_DO_ABORT), 0))) 645 646 #else 647 # if defined LEMON_DISABLE_ASSERTS 648 649 # define LEMON_ASSERT(exp, msg) (static_cast<void> (0)) 650 651 # else 652 # define LEMON_ASSERT(exp, msg) \ 653 (static_cast<void> (!!(exp) ? 0 : ( \ 654 LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \ 655 __PRETTY_FUNCTION__, \ 656 msg, #exp, LEMON_ASSERT_DO_ABORT), 0))) 657 # endif 658 #endif 630 659 631 660 /**
Note: See TracChangeset
for help on using the changeset viewer.