mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
31 lines
917 B
C++
31 lines
917 B
C++
|
#ifndef MY_ASSERT_HPP
|
||
|
#define MY_ASSERT_HPP
|
||
|
|
||
|
#ifndef NDEBUG
|
||
|
# define m_assert(condition, message) \
|
||
|
do { \
|
||
|
if (! (condition)) { \
|
||
|
std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
|
||
|
<< " line " << __LINE__ << ": " << message << std::endl; \
|
||
|
std::terminate(); \
|
||
|
} \
|
||
|
} while (false)
|
||
|
|
||
|
# define c_assert(condition) \
|
||
|
do { \
|
||
|
if (! (condition)) { \
|
||
|
std::cerr << "Assertion `" #condition "` failed in " << __FILE__ \
|
||
|
<< " line " << __LINE__ << std::endl; \
|
||
|
std::terminate(); \
|
||
|
} \
|
||
|
} while (false)
|
||
|
#else
|
||
|
#include <exception>
|
||
|
#include <iostream>
|
||
|
|
||
|
# define m_c_assert(condition, message) do { (void)sizeof(condition); (void)sizeof(message); } while (false)
|
||
|
# define c_assert(condition) do { (void)sizeof(condition); } while (false)
|
||
|
#endif
|
||
|
|
||
|
#endif // MY_ASSERT_HPP
|