#pragma once #include // For convenience, bring in soft assertions with assert(). #include // Allow the client to define their own LOGE() macro. #ifndef LOGE #include #define LOGE(...) \ { \ fprintf(stderr, "[ASSERT] %s:%d: ", __FILE__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ } #endif // LOGE #define TRAP() raise(SIGTRAP) /// Unconditional hard assert. #define FAIL(message) \ LOGE(message); \ TRAP(); /// Conditional hard assert. #define ASSERT(condition) \ if (!condition) { \ LOGE("Assertion failed: " #condition) \ TRAP(); \ }