NW4F G3d
Loading...
Searching...
No Matches
g3d_assert.h
Go to the documentation of this file.
1#ifndef NW_G3D_ASSERT_H_
2#define NW_G3D_ASSERT_H_
3
4#include <cafe/os.h>
5
6#ifndef NW_G3D_ASSERTMSG
7#if NW_G3D_IS_DEBUG || NW_G3D_IS_DEVELOP
8#define NW_G3D_ASSERTMSG(exp, ...)
9 (void) ((exp) || (OSReport(__VA_ARGS__),
10 OSReport("\t%s(%d)\n", NW_G3D_CODE_POSITION_NAME, __LINE__),
11 NW_G3D_DEBUG_BREAK(), ::exit(EXIT_FAILURE), 0))
12#else
13#define NW_G3D_ASSERTMSG(exp, ...) ((void)0)
14#endif
15#endif
16
17#define NW_G3D_ASSERT(exp)
18 NW_G3D_ASSERTMSG((exp), "NW: Failed assertion. " #exp "\n")
19
20#define NW_G3D_ASSERT_NOT_NULL(exp)
21 NW_G3D_ASSERTMSG((exp) != NULL, "NW: Pointer must not be NULL. ("#exp")\n")
22
23#define NW_G3D_ASSERT_INDEX_BOUNDS(index, size)
24 NW_G3D_ASSERTMSG(static_cast<uint>(index) < static_cast<uint>(size),
25 "NW: " #index " is out of bounds. (%d)\n"
26 "0 <= " #index " < %d is not satisfied.\n",
27 static_cast<int>(index), static_cast<int>(size))
28
29#define NW_G3D_ASSERT_ALIGNMENT(value, alignment)
30 NW_G3D_ASSERTMSG(static_cast<uint>((value) & (alignment - 1)) == 0,
31 "NW: Failed alignment. \n"
32 "value: 0x%x\n"
33 "alignment: %d\n",
34 value, static_cast<int>(alignment))
35
36#define NW_G3D_ASSERT_ADDR_ALIGNMENT(addr, alignment)
37 NW_G3D_ASSERTMSG((reinterpret_cast<uintptr_t>(addr) & (alignment - 1)) == 0,
38 "NW: Failed alignment. \n"
39 "ptr: 0x%x\n"
40 "alignment: %d\n",
41 reinterpret_cast<uintptr_t>(addr), static_cast<int>(alignment))
42
43#define NW_G3D_NOT_IMPLEMENTED()
44 NW_G3D_ASSERTMSG(0, "NW: Not implemented yet.\n")
45
46#define NW_G3D_NOT_SUPPORTED()
47 NW_G3D_ASSERTMSG(0, "NW: Not supported.\n")
48
49#if defined(_DEBUG) || defined(NW_DEBUG) || defined(NW_DEVELOP)
50#define NW_G3D_WARNING(exp, ...)
51 (void) ((exp) || (OSReport("NW: "), OSReport(__VA_ARGS__),
52 OSReport("\t%s(%d)\n", NW_G3D_CODE_POSITION_NAME, __LINE__), 0))
53#else
54#define NW_G3D_WARNING(exp, ... ) ((void)0)
55#endif
56
57namespace nw { namespace g3d {
58
59void DebugPrint(const char* format, ...);
60
61} } // namespace nw::g3d
62
63#define NW_G3D_DEBUG_BREAK()
64
65#endif // NW_G3D_ASSERT_H_
#define NW_G3D_ASSERTMSG(exp,...)
Definition g3d_assert.h:13
Definition g3d_GfxManage.cpp:10
void DebugPrint(const char *format,...)