SOPHIA_ASSERT

This commit is contained in:
2026-09-09 02:02:03 -07:00
parent 73d2121bc1
commit 9aef3f57fc
8 changed files with 57 additions and 26 deletions
+26
View File
@@ -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