lemon/assert.h
changeset 223 cfadfeef706f
parent 210 81cfc04531e8
child 218 0d6511647639
equal deleted inserted replaced
5:36a25a448990 6:f32b094da7a3
    64 
    64 
    65 #undef LEMON_ASSERT
    65 #undef LEMON_ASSERT
    66 #undef LEMON_FIXME
    66 #undef LEMON_FIXME
    67 #undef LEMON_DEBUG
    67 #undef LEMON_DEBUG
    68 
    68 
    69 #if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
    69 #if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
    70   (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
    70   (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
    71   (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    71   (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
    72 #error "LEMON assertion system is not set properly"
    72 #error "LEMON assertion system is not set properly"
    73 #endif
    73 #endif
    74 
    74 
    75 #if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +                \
    75 #if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
    76      (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +                \
    76      (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
    77      (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||        \
    77      (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
    78      defined(LEMON_ENABLE_ASSERTS)) &&                        \
    78      defined(LEMON_ENABLE_ASSERTS)) &&                  \
    79   (defined(LEMON_DISABLE_ASSERTS) ||                        \
    79   (defined(LEMON_DISABLE_ASSERTS) ||                    \
    80    defined(NDEBUG))
    80    defined(NDEBUG))
    81 #error "LEMON assertion system is not set properly"
    81 #error "LEMON assertion system is not set properly"
    82 #endif
    82 #endif
    83 
    83 
    84 
    84 
   166 /// The assertion mode can also be changed within one compilation unit.
   166 /// The assertion mode can also be changed within one compilation unit.
   167 /// If the macros are redefined with other settings and the
   167 /// If the macros are redefined with other settings and the
   168 /// \ref lemon/assert.h "assert.h" file is reincluded, then the
   168 /// \ref lemon/assert.h "assert.h" file is reincluded, then the
   169 /// behaviour is changed appropiately to the new settings.
   169 /// behaviour is changed appropiately to the new settings.
   170 #  define LEMON_ASSERT(exp, msg)                                        \
   170 #  define LEMON_ASSERT(exp, msg)                                        \
   171   (static_cast<void> (!!(exp) ? 0 : (                                        \
   171   (static_cast<void> (!!(exp) ? 0 : (                                   \
   172     LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                                \
   172     LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
   173                          LEMON_FUNCTION_NAME,                                \
   173                          LEMON_FUNCTION_NAME,                           \
   174                          ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   174                          ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   175 
   175 
   176 /// \ingroup exceptions
   176 /// \ingroup exceptions
   177 ///
   177 ///
   178 /// \brief Macro for mark not yet implemented features.
   178 /// \brief Macro for mark not yet implemented features.
   182 /// \code
   182 /// \code
   183 ///   LEMON_ASSERT(false, msg);
   183 ///   LEMON_ASSERT(false, msg);
   184 /// \endcode
   184 /// \endcode
   185 ///
   185 ///
   186 /// \see LEMON_ASSERT
   186 /// \see LEMON_ASSERT
   187 #  define LEMON_FIXME(msg)                                                \
   187 #  define LEMON_FIXME(msg)                                              \
   188   (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   188   (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   189                         ::lemon::_assert_bits::cstringify(msg),          \
   189                         ::lemon::_assert_bits::cstringify(msg),         \
   190                         static_cast<const char*>(0)))
   190                         static_cast<const char*>(0)))
   191 
   191 
   192 /// \ingroup exceptions
   192 /// \ingroup exceptions
   193 ///
   193 ///
   194 /// \brief Macro for internal assertions
   194 /// \brief Macro for internal assertions
   210 /// This macro works like the \c LEMON_ASSERT macro, therefore the
   210 /// This macro works like the \c LEMON_ASSERT macro, therefore the
   211 /// current behaviour depends on the settings of \c LEMON_ASSERT
   211 /// current behaviour depends on the settings of \c LEMON_ASSERT
   212 /// macro.
   212 /// macro.
   213 ///
   213 ///
   214 /// \see LEMON_ASSERT
   214 /// \see LEMON_ASSERT
   215 #  define LEMON_DEBUG(exp, msg)                                                \
   215 #  define LEMON_DEBUG(exp, msg)                                         \
   216   (static_cast<void> (!!(exp) ? 0 : (                                        \
   216   (static_cast<void> (!!(exp) ? 0 : (                                   \
   217     LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
   217     LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                            \
   218                          LEMON_FUNCTION_NAME,                                \
   218                          LEMON_FUNCTION_NAME,                           \
   219                          ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   219                          ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
   220 
   220 
   221 #else
   221 #else
   222 
   222 
   223 #  ifndef LEMON_ASSERT_HANDLER
   223 #  ifndef LEMON_ASSERT_HANDLER
   224 #    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
   224 #    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
   225 #    define LEMON_FIXME(msg) (static_cast<void>(0))
   225 #    define LEMON_FIXME(msg) (static_cast<void>(0))
   226 #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   226 #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   227 #  else
   227 #  else
   228 #    define LEMON_ASSERT(exp, msg)                                        \
   228 #    define LEMON_ASSERT(exp, msg)                                      \
   229        (static_cast<void> (!!(exp) ? 0 : (                                \
   229        (static_cast<void> (!!(exp) ? 0 : (                              \
   230         LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                        \
   230         LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                        \
   231                              LEMON_FUNCTION_NAME,                        \
   231                              LEMON_FUNCTION_NAME,                       \
   232                              ::lemon::_assert_bits::cstringify(msg),        \
   232                              ::lemon::_assert_bits::cstringify(msg),    \
   233                              #exp), 0)))
   233                              #exp), 0)))
   234 #    define LEMON_FIXME(msg)                                                \
   234 #    define LEMON_FIXME(msg)                                            \
   235        (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
   235        (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
   236                              ::lemon::_assert_bits::cstringify(msg),        \
   236                              ::lemon::_assert_bits::cstringify(msg),    \
   237                              static_cast<const char*>(0)))
   237                              static_cast<const char*>(0)))
   238 
   238 
   239 #    if LEMON_ENABLE_DEBUG
   239 #    if LEMON_ENABLE_DEBUG
   240 #      define LEMON_DEBUG(exp, msg)
   240 #      define LEMON_DEBUG(exp, msg)
   241          (static_cast<void> (!!(exp) ? 0 : (         \
   241          (static_cast<void> (!!(exp) ? 0 : (                            \
   242            LEMON_ASSERT_HANDLER(__FILE__, __LINE__,  \
   242            LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                     \
   243                                 LEMON_FUNCTION_NAME, \
   243                                 LEMON_FUNCTION_NAME,                    \
   244                                 ::lemon::_assert_bits::cstringify(msg),     \
   244                                 ::lemon::_assert_bits::cstringify(msg), \
   245                                 #exp), 0)))
   245                                 #exp), 0)))
   246 #    else
   246 #    else
   247 #      define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   247 #      define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
   248 #    endif
   248 #    endif
   249 #  endif
   249 #  endif
   250 
   250 
   251 #endif
   251 #endif
   252 
       
   253 #ifdef DOXYGEN
       
   254 
       
   255 
       
   256 #else
       
   257 
       
   258 
       
   259 #endif
       
   260 
       
   261