mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
chore(error): add STORM_ASSERT_VOID and improve assertion macros
This commit is contained in:
parent
bc499d065c
commit
a56c0c6fe0
2 changed files with 26 additions and 10 deletions
|
|
@ -3,7 +3,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
void SErrDisplayAppFatal(const char* format, ...) {
|
||||
[[ noreturn ]] void SErrDisplayAppFatal(const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
|
|
|
|||
|
|
@ -3,23 +3,39 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
|
||||
#define ERROR_INVALID_PARAMETER 0x57
|
||||
#endif
|
||||
|
||||
#if defined(NDEBUG)
|
||||
#define STORM_ASSERT(x) \
|
||||
if (!(x)) { \
|
||||
SErrSetLastError(0x57); \
|
||||
return 0; \
|
||||
}
|
||||
#define STORM_ASSERT(x) \
|
||||
if (!(x)) { \
|
||||
SErrSetLastError(ERROR_INVALID_PARAMETER); \
|
||||
return 0; \
|
||||
} \
|
||||
(void)0
|
||||
#define STORM_ASSERT_VOID(x) \
|
||||
if (!(x)) { \
|
||||
SErrSetLastError(ERROR_INVALID_PARAMETER); \
|
||||
return; \
|
||||
} \
|
||||
(void)0
|
||||
#else
|
||||
#define STORM_ASSERT(x) \
|
||||
if (!(x)) { \
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__); \
|
||||
SErrDisplayAppFatal(#x); \
|
||||
SErrSetLastError(0x57); \
|
||||
return 0; \
|
||||
}
|
||||
} \
|
||||
(void)0
|
||||
#define STORM_ASSERT_VOID(x) \
|
||||
if (!(x)) { \
|
||||
SErrPrepareAppFatal(__FILE__, __LINE__); \
|
||||
SErrDisplayAppFatal(#x); \
|
||||
} \
|
||||
(void)0
|
||||
#endif
|
||||
|
||||
void SErrDisplayAppFatal(const char* format, ...);
|
||||
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...);
|
||||
|
||||
int32_t SErrDisplayError(uint32_t errorcode, const char* filename, int32_t linenumber, const char* description, int32_t recoverable, uint32_t exitcode, uint32_t a7);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue