COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/assert.h

    r290 r218  
    2828namespace lemon {
    2929
    30   inline void assert_fail_abort(const char *file, int line,
    31                                 const char *function, const char* message,
    32                                 const char *assertion)
     30  inline void assert_fail_log(const char *file, int line, const char *function,
     31                              const char *message, const char *assertion)
    3332  {
    3433    std::cerr << file << ":" << line << ": ";
     
    3938      std::cerr << " (assertion '" << assertion << "' failed)";
    4039    std::cerr << std::endl;
     40  }
     41
     42  inline void assert_fail_abort(const char *file, int line,
     43                                const char *function, const char* message,
     44                                const char *assertion)
     45  {
     46    assert_fail_log(file, line, function, message, assertion);
    4147    std::abort();
    4248  }
     
    5864
    5965#undef LEMON_ASSERT
     66#undef LEMON_FIXME
    6067#undef LEMON_DEBUG
    6168
    62 #if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
     69#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
     70  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    6371  (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    6472#error "LEMON assertion system is not set properly"
    6573#endif
    6674
    67 #if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
     75#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
     76     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    6877     (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    6978     defined(LEMON_ENABLE_ASSERTS)) &&                  \
     
    7483
    7584
    76 #if defined LEMON_ASSERT_ABORT
     85#if defined LEMON_ASSERT_LOG
     86#  undef LEMON_ASSERT_HANDLER
     87#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log
     88#elif defined LEMON_ASSERT_ABORT
    7789#  undef LEMON_ASSERT_HANDLER
    7890#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
     
    96108#  elif defined _MSC_VER
    97109#    define LEMON_FUNCTION_NAME (__FUNCSIG__)
    98 #  elif __STDC_VERSION__ >= 199901L
     110#  else
    99111#    define LEMON_FUNCTION_NAME (__func__)
    100 #  else
    101 #    define LEMON_FUNCTION_NAME ("<unknown>")
    102112#  endif
    103113#endif
     
    109119/// \brief Macro for assertion with customizable message
    110120///
    111 /// Macro for assertion with customizable message.
    112 /// \param exp An expression that must be convertible to \c bool.  If it is \c
    113 /// false, then an assertion is raised. The concrete behaviour depends on the
    114 /// settings of the assertion system.
    115 /// \param msg A <tt>const char*</tt> parameter, which can be used to provide
    116 /// information about the circumstances of the failed assertion.
     121/// Macro for assertion with customizable message.  \param exp An
     122/// expression that must be convertible to \c bool.  If it is \c
     123/// false, then an assertion is raised. The concrete behaviour depends
     124/// on the settings of the assertion system.  \param msg A <tt>const
     125/// char*</tt> parameter, which can be used to provide information
     126/// about the circumstances of the failed assertion.
    117127///
    118128/// The assertions are enabled in the default behaviour.
     
    128138/// The checking is also disabled when the standard macro \c NDEBUG is defined.
    129139///
    130 /// As a default behaviour the failed assertion prints a short log message to
    131 /// the standard error and aborts the execution.
    132 ///
    133 /// However, the following modes can be used in the assertion system:
    134 /// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to
    135 ///   the standard error and aborts the program. It is the default behaviour.
     140/// The LEMON assertion system has a wide range of customization
     141/// properties. As a default behaviour the failed assertion prints a
     142/// short log message to the standard error and aborts the execution.
     143///
     144/// The following modes can be used in the assertion system:
     145///
     146/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
     147///   message to the standard error and continues the execution.
     148/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c
     149///   LEMON_ASSERT_LOG, but it aborts the program. It is the default
     150///   behaviour.
    136151/// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
    137152///   function.
     
    161176/// \ingroup exceptions
    162177///
     178/// \brief Macro for mark not yet implemented features.
     179///
     180/// Macro for mark not yet implemented features and outstanding bugs.
     181/// It is close to be the shortcut of the following code:
     182/// \code
     183///   LEMON_ASSERT(false, msg);
     184/// \endcode
     185///
     186/// \see LEMON_ASSERT
     187#  define LEMON_FIXME(msg)                                              \
     188  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
     189                        ::lemon::_assert_bits::cstringify(msg),         \
     190                        static_cast<const char*>(0)))
     191
     192/// \ingroup exceptions
     193///
    163194/// \brief Macro for internal assertions
    164195///
     
    192223#  ifndef LEMON_ASSERT_HANDLER
    193224#    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
     225#    define LEMON_FIXME(msg) (static_cast<void>(0))
    194226#    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
    195227#  else
     
    200232                             ::lemon::_assert_bits::cstringify(msg),    \
    201233                             #exp), 0)))
     234#    define LEMON_FIXME(msg)                                            \
     235       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
     236                             ::lemon::_assert_bits::cstringify(msg),    \
     237                             static_cast<const char*>(0)))
     238
    202239#    if LEMON_ENABLE_DEBUG
    203240#      define LEMON_DEBUG(exp, msg)                                     \
Note: See TracChangeset for help on using the changeset viewer.