Make lovrAssert act like a function

`do {} while(0)` is the perfect way to make function-like macro act like a real function (require ;, encapsulate local variables)
This commit is contained in:
Ilya 2024-03-03 14:37:14 +03:00 committed by GitHub
parent 1ec0a41bb8
commit 4139f0f180
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -37,7 +37,7 @@
typedef void errorFn(void*, const char*, va_list);
void lovrSetErrorCallback(errorFn* callback, void* userdata);
LOVR_NORETURN void lovrThrow(const char* format, ...);
#define lovrAssert(c, ...) if (!(c)) { lovrThrow(__VA_ARGS__); }
#define lovrAssert(c, ...) do { if (!(c)) { lovrThrow(__VA_ARGS__); } } while(0)
#define lovrUnreachable() lovrThrow("Unreachable")
#ifdef LOVR_UNCHECKED