MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
mgdl-assert.h
Go to the documentation of this file.
1#pragma once
2
8#include <mgdl/mgdl-types.h>
9
10#ifdef __cplusplus
11extern "C"
12{
13#endif
25 void AssertFunctionPrintf(const char* filename, int lineNumber, const char* message, ...);
26
37 void AssertFunctionPrint(const char* filename, int lineNumber, const char* message);
38
39
40#ifdef __cplusplus
41}
42#endif
43
44/* muffintrap:
45 This code is mostly from Game Programming Gems 1 article
46 "Squeezing More Out of Assert" written by Steve Rabin
47*/
48#ifdef GEKKO
49 // The ##__VA_ARGS is needed in GNU C++17 so that
50 // the variadic parameters are optional. Otherwise the comma
51 // after message causes compile error.
52 // See: https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
53 #define mgdl_assert_printf(test, message, ...) \
54 if ((test) == false) \
55 { \
56 AssertFunctionPrintf(__FILE__, __LINE__, message, ##__VA_ARGS__); \
57 }
58#else
59 // On Windows and Mac the ##__VA_ARGS__ does not work
60
61#ifdef MGDL_PLATFORM_MAC
62 #pragma clang diagnostic push
63 #pragma clang diagnostic ignored "-Wvariadic-macros"
64#endif
65
66 #define mgdl_assert_printf(test, message, ...) \
67 if ((test) == false) \
68 { \
69 AssertFunctionPrintf(__FILE__, __LINE__, message, __VA_ARGS__); \
70 }
71
72#ifdef MGDL_PLATFORM_MAC
73 #pragma clang diagnostic pop
74#endif
75
76#endif
77
78// These are same for PC and Wii
79
80#define mgdl_assert_print(test, message) \
81if ((test) == false) \
82{ \
83 AssertFunctionPrint(__FILE__, __LINE__, message); \
84}
85
86#define mgdl_assert_test(test) \
87if ((test) == false) \
88{ \
89 AssertFunctionPrint(__FILE__, __LINE__, #test); \
90}
91
92
void AssertFunctionPrint(const char *filename, int lineNumber, const char *message)
If the assert fails, break into assert display loop and ask if assert should be ignored.
Definition pc-assert.cpp:22
void AssertFunctionPrintf(const char *filename, int lineNumber, const char *message,...)
If the assert fails, break into assert display loop and ask if assert should be ignored.
Definition pc-assert.cpp:6
Library types, macros, defines and enums header.