SOPHIA_ASSERT
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Usage:
|
||||
* SOPHIA_ASSERT(pipelineLayout != nullptr);
|
||||
* SOPHIA_ASSERT(index < count, "index", index, "out of bounds:", count);
|
||||
*
|
||||
* Compiled out entirely in release (NDEBUG) builds, matching <cassert>'s
|
||||
* assert() semantics: don't rely on side effects inside the condition.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sophia/util/logger.hpp>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define SOPHIA_ASSERT(condition, ...) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
::sophia::log::fatal("Assertion failed:", #condition, "at", __FILE__, \
|
||||
":", __LINE__ __VA_OPT__(, ) __VA_ARGS__); \
|
||||
std::abort(); \
|
||||
} \
|
||||
} while (false)
|
||||
#else
|
||||
#define SOPHIA_ASSERT(condition, ...) ((void)0)
|
||||
#endif // !NDEBUG
|
||||
Reference in New Issue
Block a user