feat(error): implement SErrSetLastError and SErrGetLastError functions

This commit is contained in:
Tristan 'Natrist' Cormier 2023-01-27 11:25:57 -05:00 committed by GitHub
parent 095b042583
commit 630e6dbb1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -3,6 +3,12 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#if defined(WHOA_SYSTEM_WIN)
#include <Windows.h>
#endif
static uint32_t s_lasterror = ERROR_SUCCESS;
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...) { [[noreturn]] void SErrDisplayAppFatal(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@ -70,5 +76,13 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber) {
} }
void SErrSetLastError(uint32_t errorcode) { void SErrSetLastError(uint32_t errorcode) {
// TODO s_lasterror = errorcode;
#if defined(WHOA_SYSTEM_WIN)
SetLastError(errorcode);
#endif
}
uint32_t SErrGetLastError() {
return s_lasterror;
} }

View file

@ -4,10 +4,11 @@
#include <cstdint> #include <cstdint>
#if defined(WHOA_SYSTEM_WIN) #if defined(WHOA_SYSTEM_WIN)
#include <winerror.h> #include <WinError.h>
#endif #endif
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX) #if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
#define ERROR_SUCCESS 0x0
#define ERROR_INVALID_PARAMETER 0x57 #define ERROR_INVALID_PARAMETER 0x57
#endif #endif
@ -40,4 +41,6 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber);
void SErrSetLastError(uint32_t errorcode); void SErrSetLastError(uint32_t errorcode);
uint32_t SErrGetLastError();
#endif #endif