//
// Created by spenc on 5/18/2025.
//

#ifndef MACROS_H
#define MACROS_H


#include <iostream>
#include <cstdlib>

#if defined(_WIN32)
#define OX_DEBUG_BREAK() __debugbreak()
#elif defined(__unix__) || defined(__APPLE__)
#include <signal.h>
#define OX_DEBUG_BREAK() raise(SIGTRAP)
#else
#define OX_DEBUG_BREAK() ((void)0)
#endif

// ========== ASSERT ==========
// In debug builds: breaks and logs.
// In release builds: removed entirely.
#ifdef _DEBUG
#define OX_ASSERT(condition, message)                                          \
do {                                                                       \
if (!(condition)) {                                                    \
std::cerr << "\n[ASSERTION] " << #condition << "\n"         \
<< "Message: " << message << "\n"                        \
<< "File: " << __FILE__ << ":" << __LINE__ << "\n";      \
OX_DEBUG_BREAK();                                                  \
}                                                                      \
} while (0)
#else
#define OX_ASSERT(condition, message) ((void)0)
#endif

// ========== VERIFY ==========
// In debug builds: asserts.
// In release builds: just evaluates the condition.
#ifdef _DEBUG
#define OX_VERIFY(condition, message) OX_ASSERT(condition, message)
#else
#define OX_VERIFY(condition, message) ((void)(condition))
#endif


#endif //MACROS_H
