Create LOVR_NORETURN abstracting the contradictory noreturn implementations in C11 and C++11

This commit is contained in:
mcc 2023-03-05 19:16:59 -05:00
parent d8e856e6e0
commit c3b63e60ba
1 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,12 @@
#define LOVR_THREAD_LOCAL __thread
#endif
#ifdef __cplusplus
#define LOVR_NORETURN [[noreturn]]
#else
#define LOVR_NORETURN _Noreturn
#endif
#ifndef M_PI
#define M_PI 3.14159265358979
#endif
@ -30,7 +36,7 @@
// Error handling
typedef void errorFn(void*, const char*, va_list);
void lovrSetErrorCallback(errorFn* callback, void* userdata);
_Noreturn void lovrThrow(const char* format, ...);
LOVR_NORETURN void lovrThrow(const char* format, ...);
#define lovrAssert(c, ...) if (!(c)) { lovrThrow(__VA_ARGS__); }
#define lovrUnreachable() lovrThrow("Unreachable")