mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-29 03:16:56 -05:00
Add more asserts
This commit is contained in:
parent
56cd831ec8
commit
099ce2d91d
3 changed files with 42 additions and 6 deletions
|
|
@ -30,3 +30,27 @@ namespace assert
|
|||
struct StaticAssert<true>
|
||||
{};
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
#define ASSERT_NOT_NULL(ptr)
|
||||
|
||||
#else
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#define ASSERT_NOT_NULL(ptr) \
|
||||
do { \
|
||||
auto *_tmp = (ptr); \
|
||||
if((_tmp) == nullptr) { \
|
||||
std::cerr << "ASSERT_NOT_NULL failed\n" \
|
||||
<< " expression: \"" #ptr "\"\n" \
|
||||
<< " file: " << __FILE__ << "\n" \
|
||||
<< " line: " << __LINE__ << "\n" \
|
||||
<< " function: " << __func__ << "\n"; \
|
||||
assert((_tmp) != nullptr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue