SDEngine
Game Engine
Loading...
Searching...
No Matches
base.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <spdlog/spdlog.h>
4
5
#include "
SD/core/logging.hpp
"
6
7
#if defined(_MSC_VER)
8
#define TRAP() __debugbreak()
9
#elif defined(__GNUC__) || defined(__clang__)
10
#define TRAP() __builtin_trap()
11
#else
12
#error Unknown trap intrinsic for compiler.
13
#endif
14
#define ASSERT_ALWAYS(x) \
15
do { \
16
if (!(x)) { \
17
spdlog::critical("ASSERT FAILED: {} at {}:{}", #x, __FILE__, __LINE__); \
18
TRAP(); \
19
} \
20
} while (0)
21
22
#ifndef NDEBUG
23
#define ASSERT(x) ASSERT_ALWAYS(x)
24
#else
25
#define ASSERT(x) (void)(x)
26
#endif
27
#define INVALID_PATH ASSERT(!"Invalid Path!")
28
#define NOT_IMPLEMENTED ASSERT(!"Not Implemented!")
29
#define NO_OP ((void)0)
30
31
32
namespace
sd
{
33
// TODO(docs): Document Abort() overloads
34
// - Explain when to use vs exceptions
35
// - Note about spdlog shutdown behavior
36
// - Thread-safety considerations
41
[[noreturn]]
inline
void
engine_abort
(
const
std::string& message) {
42
log::engine::critical(
"Fatal error: {}"
, message);
43
spdlog::shutdown();
44
std::abort();
45
}
46
[[noreturn]]
inline
void
engine_abort
() {
47
spdlog::shutdown();
48
std::abort();
49
}
50
51
}
// namespace sd
logging.hpp
sd
Definition
Application.hpp:28
sd::engine_abort
void engine_abort()
Definition
base.hpp:46
SD
include
SD
core
base.hpp
Generated by
1.9.8