lemon/assert.h
changeset 279 6307bbbf285b
parent 266 112ed801139d
child 290 f6899946c1ac
     1.1 --- a/lemon/assert.h	Mon Sep 22 15:33:23 2008 +0200
     1.2 +++ b/lemon/assert.h	Tue Sep 23 18:42:49 2008 +0200
     1.3 @@ -27,8 +27,9 @@
     1.4  
     1.5  namespace lemon {
     1.6  
     1.7 -  inline void assert_fail_log(const char *file, int line, const char *function,
     1.8 -                              const char *message, const char *assertion)
     1.9 +  inline void assert_fail_abort(const char *file, int line,
    1.10 +                                const char *function, const char* message,
    1.11 +                                const char *assertion)
    1.12    {
    1.13      std::cerr << file << ":" << line << ": ";
    1.14      if (function)
    1.15 @@ -37,13 +38,6 @@
    1.16      if (assertion)
    1.17        std::cerr << " (assertion '" << assertion << "' failed)";
    1.18      std::cerr << std::endl;
    1.19 -  }
    1.20 -
    1.21 -  inline void assert_fail_abort(const char *file, int line,
    1.22 -                                const char *function, const char* message,
    1.23 -                                const char *assertion)
    1.24 -  {
    1.25 -    assert_fail_log(file, line, function, message, assertion);
    1.26      std::abort();
    1.27    }
    1.28  
    1.29 @@ -63,17 +57,14 @@
    1.30  #endif // LEMON_ASSERT_H
    1.31  
    1.32  #undef LEMON_ASSERT
    1.33 -#undef LEMON_FIXME
    1.34  #undef LEMON_DEBUG
    1.35  
    1.36 -#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
    1.37 -  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    1.38 +#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    1.39    (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    1.40  #error "LEMON assertion system is not set properly"
    1.41  #endif
    1.42  
    1.43 -#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
    1.44 -     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    1.45 +#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    1.46       (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    1.47       defined(LEMON_ENABLE_ASSERTS)) &&                  \
    1.48    (defined(LEMON_DISABLE_ASSERTS) ||                    \
    1.49 @@ -82,10 +73,7 @@
    1.50  #endif
    1.51  
    1.52  
    1.53 -#if defined LEMON_ASSERT_LOG
    1.54 -#  undef LEMON_ASSERT_HANDLER
    1.55 -#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log
    1.56 -#elif defined LEMON_ASSERT_ABORT
    1.57 +#if defined LEMON_ASSERT_ABORT
    1.58  #  undef LEMON_ASSERT_HANDLER
    1.59  #  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
    1.60  #elif defined LEMON_ASSERT_CUSTOM
    1.61 @@ -107,8 +95,10 @@
    1.62  #    define LEMON_FUNCTION_NAME (__PRETTY_FUNCTION__)
    1.63  #  elif defined _MSC_VER
    1.64  #    define LEMON_FUNCTION_NAME (__FUNCSIG__)
    1.65 +#  elif __STDC_VERSION__ >= 199901L
    1.66 +#    define LEMON_FUNCTION_NAME (__func__)
    1.67  #  else
    1.68 -#    define LEMON_FUNCTION_NAME (__func__)
    1.69 +#    define LEMON_FUNCTION_NAME ("<unknown>")
    1.70  #  endif
    1.71  #endif
    1.72  
    1.73 @@ -118,12 +108,12 @@
    1.74  ///
    1.75  /// \brief Macro for assertion with customizable message
    1.76  ///
    1.77 -/// Macro for assertion with customizable message.  \param exp An
    1.78 -/// expression that must be convertible to \c bool.  If it is \c
    1.79 -/// false, then an assertion is raised. The concrete behaviour depends
    1.80 -/// on the settings of the assertion system.  \param msg A <tt>const
    1.81 -/// char*</tt> parameter, which can be used to provide information
    1.82 -/// about the circumstances of the failed assertion.
    1.83 +/// Macro for assertion with customizable message.  
    1.84 +/// \param exp An expression that must be convertible to \c bool.  If it is \c
    1.85 +/// false, then an assertion is raised. The concrete behaviour depends on the
    1.86 +/// settings of the assertion system.
    1.87 +/// \param msg A <tt>const char*</tt> parameter, which can be used to provide
    1.88 +/// information about the circumstances of the failed assertion.
    1.89  ///
    1.90  /// The assertions are enabled in the default behaviour.
    1.91  /// You can disable them with the following code:
    1.92 @@ -137,17 +127,12 @@
    1.93  /// \endcode
    1.94  /// The checking is also disabled when the standard macro \c NDEBUG is defined.
    1.95  ///
    1.96 -/// The LEMON assertion system has a wide range of customization
    1.97 -/// properties. As a default behaviour the failed assertion prints a
    1.98 -/// short log message to the standard error and aborts the execution.
    1.99 +/// As a default behaviour the failed assertion prints a short log message to
   1.100 +/// the standard error and aborts the execution.
   1.101  ///
   1.102 -/// The following modes can be used in the assertion system:
   1.103 -///
   1.104 -/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
   1.105 -///   message to the standard error and continues the execution.
   1.106 -/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c
   1.107 -///   LEMON_ASSERT_LOG, but it aborts the program. It is the default
   1.108 -///   behaviour.
   1.109 +/// However, the following modes can be used in the assertion system:
   1.110 +/// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to
   1.111 +///   the standard error and aborts the program. It is the default behaviour.
   1.112  /// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
   1.113  ///   function.
   1.114  ///   \code
   1.115 @@ -175,22 +160,6 @@
   1.116  
   1.117  /// \ingroup exceptions
   1.118  ///
   1.119 -/// \brief Macro for mark not yet implemented features.
   1.120 -///
   1.121 -/// Macro for mark not yet implemented features and outstanding bugs.
   1.122 -/// It is close to be the shortcut of the following code:
   1.123 -/// \code
   1.124 -///   LEMON_ASSERT(false, msg);
   1.125 -/// \endcode
   1.126 -///
   1.127 -/// \see LEMON_ASSERT
   1.128 -#  define LEMON_FIXME(msg)                                              \
   1.129 -  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   1.130 -                        ::lemon::_assert_bits::cstringify(msg),         \
   1.131 -                        static_cast<const char*>(0)))
   1.132 -
   1.133 -/// \ingroup exceptions
   1.134 -///
   1.135  /// \brief Macro for internal assertions
   1.136  ///
   1.137  /// Macro for internal assertions, it is used in the library to check
   1.138 @@ -222,7 +191,6 @@
   1.139  
   1.140  #  ifndef LEMON_ASSERT_HANDLER
   1.141  #    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
   1.142 -#    define LEMON_FIXME(msg) (static_cast<void>(0))
   1.143  #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   1.144  #  else
   1.145  #    define LEMON_ASSERT(exp, msg)                                      \
   1.146 @@ -231,11 +199,6 @@
   1.147                               LEMON_FUNCTION_NAME,                       \
   1.148                               ::lemon::_assert_bits::cstringify(msg),    \
   1.149                               #exp), 0)))
   1.150 -#    define LEMON_FIXME(msg)                                            \
   1.151 -       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
   1.152 -                             ::lemon::_assert_bits::cstringify(msg),    \
   1.153 -                             static_cast<const char*>(0)))
   1.154 -
   1.155  #    if LEMON_ENABLE_DEBUG
   1.156  #      define LEMON_DEBUG(exp, msg)                                     \
   1.157           (static_cast<void> (!!(exp) ? 0 : (                            \