mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
88ba80bb61
Update container documentation Fix ISSUE_TEMPLATE Fix up documentation for quick and dirty, pulling example source directly from bundled code addresses #578
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#ifndef EXAMPLES_ASSERT_HPP
|
|
#define EXAMPLES_ASSERT_HPP
|
|
|
|
#ifndef NDEBUG
|
|
#include <exception>
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
|
|
#ifdef SOL2_CI
|
|
struct pre_main {
|
|
pre_main() {
|
|
#ifdef _MSC_VER
|
|
_set_abort_behavior(0, _WRITE_ABORT_MSG);
|
|
#endif
|
|
}
|
|
} pm;
|
|
#endif // Prevent lockup when doing Continuous Integration
|
|
|
|
# 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
|
|
# define m_assert(condition, message) do { if (false) { (void)(condition); (void)sizeof(message); } } while (false)
|
|
# define c_assert(condition) do { if (false) { (void)(condition); } } while (false)
|
|
#endif
|
|
|
|
#endif // EXAMPLES_ASSERT_HPP
|