1#pragma once
2
3#include <cstdarg>
4
5#include <basis/seadTypes.h>
6
7#ifdef SEAD_DEBUG
8#define SEAD_ASSERT_MSG(condition, message, ...) \
9 do \
10 { \
11 if (!(condition)) \
12 sead::system::HaltWithDetail(__FILE__, __LINE__, message, ##__VA_ARGS__); \
13 } while (0)
14#define SEAD_ASSERT(condition) \
15 do \
16 { \
17 if (!(condition)) \
18 sead::system::HaltWithDetailNoFormat(__FILE__, __LINE__, #condition); \
19 } while (0)
20#define SEAD_WARN(message, ...) \
21 do \
22 sead::system::Warning(__FILE__, __LINE__, message, ##__VA_ARGS__); \
23 while (0)
24#define SEAD_DEBUG_PRINT(format, ...) \
25 do \
26 sead::system::Print(format, ##__VA_ARGS__); \
27 while (0)
28#else
29#define SEAD_ASSERT_MSG(condition, message, ...) \
30 do \
31 { \
32 if (false) \
33 { \
34 static_cast<void>(condition); \
35 sead::system::detail::CheckFormat(message, ##__VA_ARGS__); \
36 } \
37 } while (0)
38#define SEAD_ASSERT(condition) \
39 do \
40 { \
41 if (false) \
42 static_cast<void>(condition); \
43 } while (0)
44#define SEAD_WARN(message, ...) \
45 do \
46 { \
47 if (false) \
48 sead::system::detail::CheckFormat(message, ##__VA_ARGS__); \
49 } while (0)
50#define SEAD_DEBUG_PRINT(format, ...) \
51 do \
52 { \
53 if (false) \
54 sead::system::detail::CheckFormat(format, ##__VA_ARGS__); \
55 } while (0)
56#endif
57
58namespace sead
59{
60namespace system
61{
62namespace detail
63{
64// Dummy function whose only purpose is to trigger a format string check.
65#ifdef __GNUC__
66[[maybe_unused]] [[gnu::format(printf, 1, 2)]]
67#endif
68inline void
69CheckFormat(const char*, ...)
70{
71}
72} // namespace detail
73
74void Halt();
75#ifdef __GNUC__
76[[gnu::format(printf, 3, 4)]]
77#endif
78void HaltWithDetail(const char* file, int line, const char* msg, ...);
79void HaltWithDetailNoFormat(const char* file, int line, const char* msg);
80void DebugBreak();
81
82#ifdef __GNUC__
83[[gnu::format(printf, 1, 2)]]
84#endif
85void Print(const char* format, ...);
86void PrintV(const char* format, std::va_list);
87void PrintString(const char* format, s32);
88
89#ifdef __GNUC__
90[[gnu::format(printf, 3, 4)]]
91#endif
92void Warning(const char* file, int line, const char* msg, ...);
93void SetWarningEnable(bool enable);
94} // namespace system
95} // namespace sead
96